use of com.tvd12.dahlia.core.entity.Collection in project ezyfox-server by youngmonkeys.
the class EzyAppSendResponseImpl method execute.
@Override
public void execute(EzyData data, Collection<EzySession> recipients, boolean encrypted, EzyTransportType transportType) {
EzyResponse response = newResponse(data);
serverContext.send(response, recipients, encrypted, transportType);
}
use of com.tvd12.dahlia.core.entity.Collection in project ezyfox-server by youngmonkeys.
the class EzyBroadcastPluginsEventImpl method getPluginContextMaps.
private EzyMapSet<EzyConstant, EzyPluginContext> getPluginContextMaps() {
Collection<EzyPluginContext> pluginContexts = context.getPluginContexts();
EzyMapSet<EzyConstant, EzyPluginContext> pluginContextMaps = new EzyHashMapSet<>();
for (EzyPluginContext pluginContext : pluginContexts) {
EzyPluginSetting pluginSetting = pluginContext.getPlugin().getSetting();
Set<EzyConstant> listenEvents = pluginSetting.getListenEvents().getEvents();
for (EzyConstant listenEvent : listenEvents) {
pluginContextMaps.addItem(listenEvent, pluginContext);
}
}
return pluginContextMaps;
}
use of com.tvd12.dahlia.core.entity.Collection in project ezyfox-server by youngmonkeys.
the class EzySendResponseImpl method execute.
@Override
public void execute(EzyResponse response, Collection<EzySession> recipients, boolean encrypted, boolean immediate, EzyTransportType transportType) {
boolean success = false;
EzyResponseApi responseApi = server.getResponseApi();
EzyArray data = response.serialize();
EzySimplePackage pack = newPackage(data, encrypted, transportType);
pack.addRecipients(recipients);
try {
responseApi.response(pack, immediate);
success = true;
} catch (Exception e) {
logger.error("send data: {}, to client: {} error", pack.getData(), getRecipientsNames(recipients), e);
} finally {
pack.release();
}
boolean debug = server.getSettings().isDebug();
if (debug && success && !ignoredLogCommands.contains(response.getCommand())) {
logger.debug("send to: {} data: {}", getRecipientsNames(recipients), data);
}
}
use of com.tvd12.dahlia.core.entity.Collection 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.dahlia.core.entity.Collection in project ezyfox-server by youngmonkeys.
the class EzyRequestHandlersImplementer method implement.
public Map<String, EzyUserRequestHandler> implement(Collection<Object> controllers) {
Map<String, EzyUserRequestHandler> handlers = new HashMap<>();
for (Object controller : controllers) {
Map<String, EzyUserRequestHandler> map = implement(controller);
for (String command : map.keySet()) {
EzyUserRequestHandler handler = map.get(command);
EzyUserRequestHandler old = handlers.put(command, handler);
if (old != null && !allowOverrideCommand) {
throw new EzyDuplicateRequestHandlerException(command, old, handler);
}
}
}
return handlers;
}
Aggregations