Search in sources :

Example 1 with Collection

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);
}
Also used : EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse)

Example 2 with Collection

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;
}
Also used : EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyConstant(com.tvd12.ezyfox.constant.EzyConstant) EzyHashMapSet(com.tvd12.ezyfox.util.EzyHashMapSet) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting)

Example 3 with Collection

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);
    }
}
Also used : EzySimplePackage(com.tvd12.ezyfoxserver.socket.EzySimplePackage) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi)

Example 4 with Collection

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));
        }
    }
}
Also used : EzyConstant(com.tvd12.ezyfox.constant.EzyConstant) EzySession(com.tvd12.ezyfoxserver.entity.EzySession)

Example 5 with Collection

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;
}
Also used : HashMap(java.util.HashMap) EzyDuplicateRequestHandlerException(com.tvd12.ezyfoxserver.support.exception.EzyDuplicateRequestHandlerException) EzyUserRequestHandler(com.tvd12.ezyfoxserver.support.handler.EzyUserRequestHandler)

Aggregations

Collection (com.tvd12.dahlia.core.entity.Collection)17 CollectionSetting (com.tvd12.dahlia.core.setting.CollectionSetting)16 EzyObject (com.tvd12.ezyfox.entity.EzyObject)13 CollectionStorage (com.tvd12.dahlia.core.storage.CollectionStorage)11 Record (com.tvd12.dahlia.core.entity.Record)10 FieldSetting (com.tvd12.dahlia.core.setting.FieldSetting)10 EzyArray (com.tvd12.ezyfox.entity.EzyArray)10 RecordConsumer (com.tvd12.dahlia.core.function.RecordConsumer)5 DatabaseSetting (com.tvd12.dahlia.core.setting.DatabaseSetting)5 CollectionExistedException (com.tvd12.dahlia.exception.CollectionExistedException)5 CollectionNotFoundException (com.tvd12.dahlia.exception.CollectionNotFoundException)5 DuplicatedIdException (com.tvd12.dahlia.exception.DuplicatedIdException)5 CommandCreateCollection (com.tvd12.dahlia.core.command.CommandCreateCollection)4 Database (com.tvd12.dahlia.core.entity.Database)4 DatabaseExistedException (com.tvd12.dahlia.exception.DatabaseExistedException)4 FindOptions (com.tvd12.dahlia.query.FindOptions)4 EzyConstant (com.tvd12.ezyfox.constant.EzyConstant)4 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)4 ArrayList (java.util.ArrayList)4 ICollection (com.tvd12.dahlia.ICollection)3