Search in sources :

Example 16 with EzyResponse

use of com.tvd12.ezyfoxserver.command.EzyResponse in project ezyfox-server by youngmonkeys.

the class EzyPluginSendResponseImpl method execute.

@Override
public void execute(EzyData data, EzySession recipient, boolean encrypted, EzyTransportType transportType) {
    EzyResponse response = newResponse(data);
    serverContext.send(response, recipient, encrypted, transportType);
}
Also used : EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse)

Example 17 with EzyResponse

use of com.tvd12.ezyfoxserver.command.EzyResponse in project ezyfox-server by youngmonkeys.

the class EzyPluginSendResponseImpl method newResponse.

protected EzyResponse newResponse(EzyData data) {
    EzyPluginSetting setting = context.getPlugin().getSetting();
    EzyRequestPluginResponseParams params = newResponseParams();
    params.setPluginId(setting.getId());
    params.setData(data);
    return new EzyRequestPluginResponse(params);
}
Also used : EzyRequestPluginResponseParams(com.tvd12.ezyfoxserver.response.EzyRequestPluginResponseParams) EzyRequestPluginResponse(com.tvd12.ezyfoxserver.response.EzyRequestPluginResponse) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting)

Example 18 with EzyResponse

use of com.tvd12.ezyfoxserver.command.EzyResponse 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 19 with EzyResponse

use of com.tvd12.ezyfoxserver.command.EzyResponse in project ezyfox-server by youngmonkeys.

the class EzyPluginSendResponseImpl 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 20 with EzyResponse

use of com.tvd12.ezyfoxserver.command.EzyResponse in project ezyfox-server by youngmonkeys.

the class EzySendResponseImpl method execute.

@Override
public void execute(EzyResponse response, EzySession recipient, boolean encrypted, boolean immediate, EzyTransportType transportType) {
    boolean success = false;
    EzyResponseApi responseApi = server.getResponseApi();
    EzyArray data = response.serialize();
    EzySimplePackage pack = newPackage(data, encrypted, transportType);
    pack.addRecipient(recipient);
    try {
        responseApi.response(pack, immediate);
        success = true;
    } catch (Exception e) {
        logger.error("send data: {}, to client: {} error", pack.getData(), recipient.getName(), e);
    } finally {
        pack.release();
    }
    boolean debug = server.getSettings().isDebug();
    if (debug && success && !ignoredLogCommands.contains(response.getCommand())) {
        logger.debug("send to: {} data: {}", recipient.getName(), data);
    }
}
Also used : EzySimplePackage(com.tvd12.ezyfoxserver.socket.EzySimplePackage) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi)

Aggregations

EzyResponse (com.tvd12.ezyfoxserver.response.EzyResponse)25 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)17 Test (org.testng.annotations.Test)12 EzyResponseApi (com.tvd12.ezyfoxserver.api.EzyResponseApi)11 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)9 EzySendResponseImpl (com.tvd12.ezyfoxserver.command.impl.EzySendResponseImpl)8 EzySimpleResponse (com.tvd12.ezyfoxserver.response.EzySimpleResponse)8 EzySimpleSettings (com.tvd12.ezyfoxserver.setting.EzySimpleSettings)8 EzyPackage (com.tvd12.ezyfoxserver.response.EzyPackage)7 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)5 EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)4 EzyArray (com.tvd12.ezyfox.entity.EzyArray)3 EzyErrorParams (com.tvd12.ezyfoxserver.response.EzyErrorParams)3 EzyAppSetting (com.tvd12.ezyfoxserver.setting.EzyAppSetting)3 EzyApplication (com.tvd12.ezyfoxserver.EzyApplication)2 EzyBroadcastEvent (com.tvd12.ezyfoxserver.command.EzyBroadcastEvent)2 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)2 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)2 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)2 EzySimpleServerReadyEvent (com.tvd12.ezyfoxserver.event.EzySimpleServerReadyEvent)2