use of com.tvd12.ezyfox.entity.EzyData in project ezyfox-server-example by tvd12.
the class HelloWorldClient method setup.
protected EzyClient setup() {
EzyClientConfig clientConfig = EzyClientConfig.builder().zoneName(ZONE_NAME).enableSSL().enableDebug().build();
EzyClients clients = EzyClients.getInstance();
EzyClient client = new EzyUTClient(clientConfig);
clients.addClient(client);
EzySetup setup = client.setup();
setup.addEventHandler(EzyEventType.CONNECTION_SUCCESS, new EzyConnectionSuccessHandler());
setup.addEventHandler(EzyEventType.CONNECTION_FAILURE, new EzyConnectionFailureHandler());
setup.addDataHandler(EzyCommand.HANDSHAKE, new ExHandshakeEventHandler());
setup.addDataHandler(EzyCommand.LOGIN, new ExLoginSuccessHandler());
setup.addDataHandler(EzyCommand.APP_ACCESS, new ExAccessAppHandler());
EzyAppSetup appSetup = setup.setupApp(APP_NAME);
appSetup.addDataHandler("greet", new ChatGreetResponseHandler());
appSetup.addDataHandler("secureChat", new SecureChatResponseHandler());
appSetup.addDataHandler("chatAll", new EzyAppDataHandler<EzyData>() {
@Override
public void handle(EzyApp app, EzyData data) {
System.out.println("chatAll: " + data);
}
});
appSetup.addDataHandler("chat1", new EzyAppDataHandler<EzyData>() {
@Override
public void handle(EzyApp app, EzyData data) {
System.out.println("chat1: " + data);
}
});
appSetup.addDataHandler("chatToMe", new EzyAppDataHandler<EzyData>() {
@Override
public void handle(EzyApp app, EzyData data) {
System.out.println("chatToMe: " + data);
}
});
appSetup.addDataHandler("err", new EzyAppDataHandler<EzyData>() {
@Override
public void handle(EzyApp app, EzyData data) {
System.out.println("error: " + data);
}
});
return client;
}
use of com.tvd12.ezyfox.entity.EzyData in project ezyfox-server-example by tvd12.
the class HelloWorldClientUdp method setup.
protected EzyClient setup() {
EzyClientConfig clientConfig = EzyClientConfig.builder().zoneName(ZONE_NAME).enableSSL().enableDebug().build();
EzyClients clients = EzyClients.getInstance();
EzyClient client = new EzyUTClient(clientConfig);
clients.addClient(client);
EzySetup setup = client.setup();
setup.addEventHandler(EzyEventType.CONNECTION_SUCCESS, new EzyConnectionSuccessHandler());
setup.addEventHandler(EzyEventType.CONNECTION_FAILURE, new EzyConnectionFailureHandler());
setup.addDataHandler(EzyCommand.HANDSHAKE, new ExHandshakeEventHandler());
setup.addDataHandler(EzyCommand.LOGIN, new ExLoginSuccessHandler());
setup.addDataHandler(EzyCommand.UDP_HANDSHAKE, new ExHandshakeSuccessHandler());
setup.addDataHandler(EzyCommand.APP_ACCESS, new ExAccessAppHandler());
EzyAppSetup appSetup = setup.setupApp(APP_NAME);
appSetup.addDataHandler("greet", new ChatGreetResponseHandler());
appSetup.addDataHandler("udpGreet", (EzyAppDataHandler<EzyData>) (app, data) -> System.out.println("udpGreet: " + data));
appSetup.addDataHandler("secureChat", new SecureChatResponseHandler());
appSetup.addDataHandler("chatAll", (EzyAppDataHandler<EzyData>) (app, data) -> System.out.println("chatAll: " + data));
appSetup.addDataHandler("chat1", (EzyAppDataHandler<EzyData>) (app, data) -> System.out.println("chat1: " + data));
appSetup.addDataHandler("chatToMe", (EzyAppDataHandler<EzyData>) (app, data) -> System.out.println("chatToMe: " + data));
appSetup.addDataHandler("err", (EzyAppDataHandler<EzyData>) (app, data) -> System.out.println("error: " + data));
return client;
}
use of com.tvd12.ezyfox.entity.EzyData in project ezyfox-server by youngmonkeys.
the class EzySimpleAppContextTest method sendMultiTest.
@Test
public void sendMultiTest() {
// given
EzyData data = mock(EzyData.class);
EzySession recipient = mock(EzySession.class);
List<EzySession> recipients = Collections.singletonList(recipient);
boolean encrypted = RandomUtil.randomBoolean();
EzyAppSendResponse sendResponse = mock(EzyAppSendResponse.class);
doNothing().when(sendResponse).execute(data, recipients, encrypted, EzyTransportType.TCP);
EzySimpleAppContext sut = new EzySimpleAppContext();
FieldUtil.setFieldValue(sut, "sendResponse", sendResponse);
// when
sut.send(data, recipients, encrypted, EzyTransportType.TCP);
// then
verify(sendResponse, times(1)).execute(data, recipients, encrypted, EzyTransportType.TCP);
}
use of com.tvd12.ezyfox.entity.EzyData in project ezyfox-server by youngmonkeys.
the class EzySimplePluginContextTest method sendMultiTest.
@Test
public void sendMultiTest() {
// given
EzyData data = mock(EzyData.class);
EzySession recipient = mock(EzySession.class);
List<EzySession> recipients = Collections.singletonList(recipient);
boolean encrypted = RandomUtil.randomBoolean();
EzyPluginSendResponse sendResponse = mock(EzyPluginSendResponse.class);
doNothing().when(sendResponse).execute(data, recipients, encrypted, EzyTransportType.TCP);
EzySimplePluginContext sut = new EzySimplePluginContext();
FieldUtil.setFieldValue(sut, "sendResponse", sendResponse);
// when
sut.send(data, recipients, encrypted, EzyTransportType.TCP);
// then
verify(sendResponse, times(1)).execute(data, recipients, encrypted, EzyTransportType.TCP);
}
use of com.tvd12.ezyfox.entity.EzyData in project ezyfox-server by youngmonkeys.
the class EzyAppSendResponseImpl method newResponse.
protected EzyResponse newResponse(EzyData data) {
EzyAppSetting setting = context.getApp().getSetting();
EzyRequestAppResponseParams params = new EzyRequestAppResponseParams();
params.setAppId(setting.getId());
params.setData(data);
return new EzyRequestAppResponse(params);
}
Aggregations