encoders.add(new CoderWrapper<Encoder>(NoOpByteArrayCoder.class, byte[].class));
encoders.add(new CoderWrapper<Encoder>(ToStringEncoder.class, Object.class));
// clustered mode
if (clusterContext != null) {
dummySession = new ClusterSession(null, null, null, null, null);
clusterContext.registerSessionListener(getEndpointPath(), new org.glassfish.tyrus.core.cluster.SessionListener() {
@Override
public void onSessionOpened(String sessionId) {
final Map<ClusterSession.DistributedMapKey, Object> distributedSessionProperties = clusterContext.getDistributedSessionProperties(sessionId);
clusteredSessions.put(sessionId, new ClusterSession(sessionId, clusterContext, distributedSessionProperties, TyrusEndpointWrapper.this, dummySession));
}
@Override
public void onSessionClosed(String sessionId) {
clusteredSessions.remove(sessionId);
}
});
clusterContext.registerBroadcastListener(getEndpointPath(), new BroadcastListener() {
@Override
public void onBroadcast(String text) {
broadcast(text, true);
}
@Override
public void onBroadcast(byte[] data) {
broadcast(ByteBuffer.wrap(data), true);
}
});
for (String sessionId : clusterContext.getRemoteSessionIds(getEndpointPath())) {
final Map<ClusterSession.DistributedMapKey, Object> distributedSessionProperties = clusterContext.getDistributedSessionProperties(sessionId);
clusteredSessions.put(sessionId, new ClusterSession(sessionId, clusterContext, distributedSessionProperties, this, dummySession));
}
} else {
dummySession = null;
}
}