Search in sources :

Example 46 with EzyArray

use of com.tvd12.ezyfoxserver.client.entity.EzyArray 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 47 with EzyArray

use of com.tvd12.ezyfoxserver.client.entity.EzyArray 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 48 with EzyArray

use of com.tvd12.ezyfoxserver.client.entity.EzyArray 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 49 with EzyArray

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

the class EzyLoginSuccessHandler method newUser.

protected EzyUser newUser(EzyArray data) {
    long userId = data.get(2, long.class);
    String username = data.get(3, String.class);
    EzySimpleUser user = new EzySimpleUser(userId, username);
    return user;
}
Also used : EzySimpleUser(com.tvd12.ezyfoxserver.client.entity.EzySimpleUser)

Example 50 with EzyArray

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

the class EzyLoginSuccessHandler method newZone.

protected EzyZone newZone(EzyArray data) {
    int zoneId = data.get(0, int.class);
    String zoneName = data.get(1, String.class);
    EzySimpleZone zone = new EzySimpleZone(client, zoneId, zoneName);
    return zone;
}
Also used : EzySimpleZone(com.tvd12.ezyfoxserver.client.entity.EzySimpleZone)

Aggregations

EzyArray (com.tvd12.ezyfox.entity.EzyArray)80 Test (org.testng.annotations.Test)45 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)30 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)17 EzyResponseApi (com.tvd12.ezyfoxserver.api.EzyResponseApi)15 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)14 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)13 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)13 EzySimpleLoginRequest (com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest)13 FieldSetting (com.tvd12.dahlia.core.setting.FieldSetting)12 EzyObject (com.tvd12.ezyfox.entity.EzyObject)12 EzyLoginController (com.tvd12.ezyfoxserver.controller.EzyLoginController)12 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)11 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)9 CollectionSetting (com.tvd12.dahlia.core.setting.CollectionSetting)8 BaseCoreTest (com.tvd12.ezyfoxserver.testing.BaseCoreTest)8 Collection (com.tvd12.dahlia.core.entity.Collection)7 EzyArray (com.tvd12.ezyfoxserver.client.entity.EzyArray)7 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)7 Record (com.tvd12.dahlia.core.entity.Record)5