Search in sources :

Example 11 with EzyData

use of com.tvd12.ezyfox.entity.EzyData in project ezyfox-server by youngmonkeys.

the class EzyRequestAppResponseTest method test.

@Test
public void test() {
    EzyRequestAppResponseParams params = new EzyRequestAppResponseParams();
    EzyData data = EzyEntityFactory.EMPTY_ARRAY;
    params.setData(data);
    params.setAppId(1);
    assert params.getAppId() == 1;
    assert params.getData() == data;
    EzyRequestAppResponse response = new EzyRequestAppResponse(params);
    assert response.getParams() == params;
    assert response.getCommand() == EzyCommand.APP_REQUEST;
    assert response.serialize().size() > 0;
    response.release();
}
Also used : EzyData(com.tvd12.ezyfox.entity.EzyData) EzyRequestAppResponse(com.tvd12.ezyfoxserver.response.EzyRequestAppResponse) EzyRequestAppResponseParams(com.tvd12.ezyfoxserver.response.EzyRequestAppResponseParams) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 12 with EzyData

use of com.tvd12.ezyfox.entity.EzyData in project ezyfox-server-android-client by youngmonkeys.

the class EzyTcpClient method send.

@Override
public void send(EzyRequest request, boolean encrypted) {
    Object cmd = request.getCommand();
    EzyData data = request.serialize();
    send((EzyCommand) cmd, (EzyArray) data, encrypted);
}
Also used : EzyData(com.tvd12.ezyfoxserver.client.entity.EzyData)

Example 13 with EzyData

use of com.tvd12.ezyfox.entity.EzyData in project ezyfox-server-android-client by youngmonkeys.

the class EzyAppResponseHandler method handle.

@Override
public void handle(EzyArray data) {
    int appId = data.get(0, int.class);
    EzyArray commandData = data.get(1, EzyArray.class);
    String cmd = commandData.get(0, String.class);
    EzyData responseData = commandData.get(1, EzyData.class, null);
    EzyApp app = client.getAppById(appId);
    if (app == null) {
        EzyLogger.info("receive message when has not joined app yet");
        return;
    }
    EzyAppDataHandler dataHandler = app.getDataHandler(cmd);
    if (dataHandler != null)
        dataHandler.handle(app, responseData);
    else
        EzyLogger.warn("app: " + app.getName() + " has no handler for command: " + cmd);
}
Also used : EzyApp(com.tvd12.ezyfoxserver.client.entity.EzyApp) EzyArray(com.tvd12.ezyfoxserver.client.entity.EzyArray) EzyData(com.tvd12.ezyfoxserver.client.entity.EzyData)

Example 14 with EzyData

use of com.tvd12.ezyfox.entity.EzyData in project ezyfox-server-android-client by youngmonkeys.

the class EzyLoginSuccessHandler method handle.

@Override
public void handle(EzyArray data) {
    EzyData responseData = data.get(4, EzyData.class);
    EzyUser user = newUser(data);
    EzyZone zone = newZone(data);
    ((EzyMeAware) client).setMe(user);
    ((EzyZoneAware) client).setZone(zone);
    handleLoginSuccess(responseData);
    EzyLogger.debug("user: " + user + " logged in successfully");
}
Also used : EzyZone(com.tvd12.ezyfoxserver.client.entity.EzyZone) EzyUser(com.tvd12.ezyfoxserver.client.entity.EzyUser) EzyZoneAware(com.tvd12.ezyfoxserver.client.entity.EzyZoneAware) EzyData(com.tvd12.ezyfoxserver.client.entity.EzyData) EzyMeAware(com.tvd12.ezyfoxserver.client.entity.EzyMeAware)

Example 15 with EzyData

use of com.tvd12.ezyfox.entity.EzyData in project ezyfox-server by youngmonkeys.

the class EzyAccessAppResponseTest method test.

@Test
public void test() {
    EzySimpleAppSetting setting = new EzySimpleAppSetting();
    EzyAccessAppParams params = new EzyAccessAppParams();
    EzyData data = EzyEntityFactory.EMPTY_ARRAY;
    params.setData(data);
    params.setApp(setting);
    assert params.getApp() == setting;
    assert params.getData() == data;
    EzyAccessAppResponse response = new EzyAccessAppResponse(params);
    assert response.getParams() == params;
    assert response.getCommand() == EzyCommand.APP_ACCESS;
    assert response.serialize().size() > 0;
    response.release();
}
Also used : EzySimpleAppSetting(com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting) EzyAccessAppResponse(com.tvd12.ezyfoxserver.response.EzyAccessAppResponse) EzyAccessAppParams(com.tvd12.ezyfoxserver.response.EzyAccessAppParams) EzyData(com.tvd12.ezyfox.entity.EzyData) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Aggregations

EzyData (com.tvd12.ezyfox.entity.EzyData)12 BaseTest (com.tvd12.test.base.BaseTest)7 Test (org.testng.annotations.Test)7 EzyArray (com.tvd12.ezyfox.entity.EzyArray)4 EzyResponse (com.tvd12.ezyfoxserver.response.EzyResponse)4 EzyApp (com.tvd12.ezyfoxserver.client.entity.EzyApp)3 EzyData (com.tvd12.ezyfoxserver.client.entity.EzyData)3 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)3 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)3 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)3 EzySimpleAppSetting (com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting)3 EzyBadRequestException (com.tvd12.ezyfox.core.exception.EzyBadRequestException)2 EzyObject (com.tvd12.ezyfox.entity.EzyObject)2 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)2 EzyClient (com.tvd12.ezyfoxserver.client.EzyClient)2 EzyClients (com.tvd12.ezyfoxserver.client.EzyClients)2 EzyUTClient (com.tvd12.ezyfoxserver.client.EzyUTClient)2 EzyClientConfig (com.tvd12.ezyfoxserver.client.config.EzyClientConfig)2 EzyAppSetup (com.tvd12.ezyfoxserver.client.setup.EzyAppSetup)2 EzySetup (com.tvd12.ezyfoxserver.client.setup.EzySetup)2