package com.megatim.fdxconsultation.service.impl.sockets;
|
|
import com.megatim.fdxconsultation.core.ifaces.stats.TableauBordManager;
|
import com.megatim.fdxconsultation.service.impl.sockets.encoders.ParticipantToFichiersDecoder;
|
import com.megatim.fdxconsultation.service.impl.sockets.encoders.ParticipantToFichiersEncoder;
|
import com.megatim.fdxconsultation.service.impl.sockets.helpers.TableauBordGlobalSessionHandler;
|
import java.io.IOException;
|
import java.util.logging.Level;
|
import java.util.logging.Logger;
|
import javax.inject.Inject;
|
import javax.websocket.EncodeException;
|
import javax.websocket.OnClose;
|
import javax.websocket.OnError;
|
import javax.websocket.OnOpen;
|
import javax.websocket.Session;
|
import javax.websocket.server.ServerEndpoint;
|
|
/**
|
*
|
* @author ASUS
|
*/
|
@ServerEndpoint(value = "/tableaubord-global",
|
encoders = {ParticipantToFichiersEncoder.class},
|
decoders = {ParticipantToFichiersDecoder.class}
|
)
|
public class TableauBordsGlobalEndpoint {
|
|
@Inject
|
private TableauBordGlobalSessionHandler tableauBordGlobalSessionHandler;
|
|
@Inject
|
private TableauBordManager manager;
|
|
@OnOpen
|
public void onOpen(Session session) {
|
try {
|
session.getBasicRemote().sendObject(manager.globalTableauBordToTypeFichiers());
|
tableauBordGlobalSessionHandler.addSession(session);
|
} catch (IOException | EncodeException ex) {
|
Logger.getLogger(TableauBordsGlobalEndpoint.class.getName()).log(Level.SEVERE, null, ex);
|
}
|
}
|
|
@OnClose
|
public void onClose(Session session) {
|
tableauBordGlobalSessionHandler.removeSession(session);
|
}
|
|
@OnError
|
public void onError(Session session, Throwable throwable) {
|
tableauBordGlobalSessionHandler.removeSession(session);
|
}
|
|
}
|