use of com.tvd12.ezyfox.constant.EzyConstant in project ezyfox-server by youngmonkeys.
the class EzyCloseSessionImpl method newResponse.
protected EzyResponse newResponse(EzyConstant reason) {
EzyDisconnectParams params = new EzyDisconnectParams();
params.setReason(reason);
return new EzyDisconnectResponse(params);
}
use of com.tvd12.ezyfox.constant.EzyConstant in project ezyfox-server by youngmonkeys.
the class EzyAbstractResponseApi method normalResponse.
protected final void normalResponse(EzyPackage pack, boolean immediate) throws Exception {
EzyConstant connectionType = getConnectionType();
Collection<EzySession> recipients = pack.getRecipients(connectionType);
if (recipients.isEmpty()) {
return;
}
Object bytes = encodeData(pack.getData());
if (immediate) {
for (EzySession session : recipients) {
session.sendNow(createPacket(bytes, pack));
}
} else {
for (EzySession session : recipients) {
session.send(createPacket(bytes, pack));
}
}
}
use of com.tvd12.ezyfox.constant.EzyConstant in project ezyfox-server by youngmonkeys.
the class EzySimpleSessionManager method provideSession.
@SuppressWarnings("unchecked")
protected S provideSession(EzyConstant connectionType) {
checkMaxSessions();
EzyAbstractSession session = (EzyAbstractSession) provideObject();
session.setLoggedIn(false);
session.setName("Session#" + COUNTER.incrementAndGet());
session.setConnectionType(connectionType);
session.setToken(newSessionToken());
session.setCreationTime(System.currentTimeMillis());
session.setCreationTime(System.currentTimeMillis());
session.setLastActivityTime(System.currentTimeMillis());
session.setLastReadTime(System.currentTimeMillis());
session.setLastWriteTime(System.currentTimeMillis());
S complete = (S) session;
sessionsById.put(complete.getId(), complete);
return complete;
}
use of com.tvd12.ezyfox.constant.EzyConstant in project ezyfox-server by youngmonkeys.
the class EzySocketDisconnectionHandler method processDisconnection.
private void processDisconnection(EzySocketDisconnection disconnection) {
try {
EzySession session = disconnection.getSession();
EzyConstant disconnectReason = disconnection.getDisconnectReason();
EzySocketDataHandlerGroup handlerGroup = removeDataHandlerGroup(session);
if (handlerGroup != null) {
handlerGroup.fireChannelInactive(disconnectReason);
} else {
logger.warn("has no handler group with session: {}, ignore disconnection: {}", session, disconnection);
}
} finally {
disconnection.release();
}
}
use of com.tvd12.ezyfox.constant.EzyConstant in project ezyfox-server by youngmonkeys.
the class EzyBroadcastPluginsEventImpl method fire.
@Override
public void fire(EzyConstant type, EzyEvent event, boolean catchException) {
logger.debug("zone: {} broadcast to plugins event: {}", getZoneName(), type);
Set<EzyPluginContext> pluginContexts = pluginContextMaps.get(type);
if (pluginContexts != null) {
for (EzyPluginContext pluginContext : pluginContexts) {
firePluginEvent(pluginContext, type, event, catchException);
}
}
}
Aggregations