Kenmegne
7 days ago 23a46b4be35277e06ec89f48730eeb694e686be8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.megatim.fdxconsultation.service.impl.sockets;
 
import com.megatim.fdxconsultation.service.impl.sockets.encoders.ConnexionStatutsDecoder;
import com.megatim.fdxconsultation.service.impl.sockets.encoders.ConnexionStatutsEncoder;
import com.megatim.fdxconsultation.service.impl.sockets.helpers.ConnexionStatutSessionHandler;
import javax.inject.Inject;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
 
/**
 *
 * @author lenovo
 */
@ServerEndpoint(value = "/connexion-status",
        encoders = {ConnexionStatutsEncoder.class},
        decoders = {ConnexionStatutsDecoder.class}
)
public class ConnexionStatutEndpoint {
 
    @Inject
    private ConnexionStatutSessionHandler connexionStatutSessionHandler;
 
    @OnOpen
    public void onOpen(Session session) {
        connexionStatutSessionHandler.addSession(session);
    }
 
    @OnClose
    public void onClose(Session session) {
        connexionStatutSessionHandler.removeSession(session);
    }
 
    @OnError
    public void onError(Session session, Throwable throwable) {
        connexionStatutSessionHandler.removeSession(session);
    }
 
}