Search in sources :

Example 21 with EzyResponse

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

the class EzyAppSendResponseImpl 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 22 with EzyResponse

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

the class EzyCloseSessionImpl method doSendToClients.

protected void doSendToClients(EzySession session, EzyConstant reason) {
    EzyResponse response = newResponse(reason);
    context.sendNow(response, session);
}
Also used : EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse)

Example 23 with EzyResponse

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

the class EzySendResponseImplTest method responseMultiSuccessCase.

@Test
public void responseMultiSuccessCase() throws Exception {
    // when
    EzySimpleSettings settings = new EzySimpleSettings();
    settings.setDebug(true);
    EzyResponseApi responseApi = mock(EzyResponseApi.class);
    EzySimpleServer server = new EzySimpleServer();
    server.setResponseApi(responseApi);
    server.setSettings(settings);
    EzySendResponseImpl cmd = new EzySendResponseImpl(server);
    EzyResponse response = new EzySimpleResponse(EzyCommand.APP_REQUEST);
    EzySession recipient = spy(EzyAbstractSession.class);
    List<EzySession> recipients = Collections.singletonList(recipient);
    // when
    cmd.execute(response, recipients, false, false, EzyTransportType.TCP);
    // then
    verify(responseApi, times(1)).response(any(EzyPackage.class), anyBoolean());
}
Also used : EzySimpleResponse(com.tvd12.ezyfoxserver.response.EzySimpleResponse) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyPackage(com.tvd12.ezyfoxserver.response.EzyPackage) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzySendResponseImpl(com.tvd12.ezyfoxserver.command.impl.EzySendResponseImpl) Test(org.testng.annotations.Test)

Example 24 with EzyResponse

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

the class EzySendResponseImplTest method responseMultiSuccessCaseButIsPong.

@Test
public void responseMultiSuccessCaseButIsPong() throws Exception {
    // when
    EzySimpleSettings settings = new EzySimpleSettings();
    settings.setDebug(true);
    EzyResponseApi responseApi = mock(EzyResponseApi.class);
    EzySimpleServer server = new EzySimpleServer();
    server.setResponseApi(responseApi);
    server.setSettings(settings);
    EzySendResponseImpl cmd = new EzySendResponseImpl(server);
    EzyResponse response = new EzySimpleResponse(EzyCommand.PONG);
    EzySession recipient = spy(EzyAbstractSession.class);
    List<EzySession> recipients = Collections.singletonList(recipient);
    // when
    cmd.execute(response, recipients, false, false, EzyTransportType.TCP);
    // then
    verify(responseApi, times(1)).response(any(EzyPackage.class), anyBoolean());
}
Also used : EzySimpleResponse(com.tvd12.ezyfoxserver.response.EzySimpleResponse) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyPackage(com.tvd12.ezyfoxserver.response.EzyPackage) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzySendResponseImpl(com.tvd12.ezyfoxserver.command.impl.EzySendResponseImpl) Test(org.testng.annotations.Test)

Example 25 with EzyResponse

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

the class EzySendResponseImplTest method responseOneSuccessCaseTest.

@Test
public void responseOneSuccessCaseTest() {
    EzySimpleSettings settings = new EzySimpleSettings();
    settings.setDebug(true);
    EzyResponseApi responseApi = spy(EzyAbstractResponseApi.class);
    EzySimpleServer server = new EzySimpleServer();
    server.setResponseApi(responseApi);
    server.setSettings(settings);
    EzySendResponseImpl cmd = new EzySendResponseImpl(server);
    EzyResponse response = new EzySimpleResponse(EzyCommand.APP_REQUEST);
    EzySession recipient = spy(EzyAbstractSession.class);
    cmd.execute(response, recipient, false, false, EzyTransportType.TCP);
}
Also used : EzySimpleResponse(com.tvd12.ezyfoxserver.response.EzySimpleResponse) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzySendResponseImpl(com.tvd12.ezyfoxserver.command.impl.EzySendResponseImpl) Test(org.testng.annotations.Test)

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