Search in sources :

Example 1 with EzyCommand

use of com.tvd12.ezyfoxserver.client.constant.EzyCommand in project ezyfox-server by youngmonkeys.

the class EzyCommandTest method test.

@Test
public void test() {
    EzyCommand value = EzyCommand.APP_ACCESS;
    assert value.getId() == EzyCommand.APP_ACCESS.getId();
    assert value == EzyCommand.valueOf(EzyCommand.APP_ACCESS.getId());
    assert value.getName().equals("APP_ACCESS");
    EzyCommand.valueOf("APP_ACCESS");
}
Also used : EzyCommand(com.tvd12.ezyfoxserver.constant.EzyCommand) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 2 with EzyCommand

use of com.tvd12.ezyfoxserver.client.constant.EzyCommand 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 3 with EzyCommand

use of com.tvd12.ezyfoxserver.client.constant.EzyCommand in project ezyfox-server-android-client by youngmonkeys.

the class EzySocketClient method processReceivedMessage.

protected void processReceivedMessage(EzyArray message) {
    int cmdId = message.get(0, int.class);
    EzyArray data = message.get(1, EzyArray.class, null);
    EzyCommand cmd = EzyCommand.valueOf(cmdId);
    printReceivedData(cmd, data);
    if (cmd == EzyCommand.DISCONNECT) {
        int reasonId = data.get(0, int.class);
        disconnectReason = reasonId;
        socketStatuses.push(EzySocketStatus.DISCONNECTING);
    } else {
        dataHandlers.handle(cmd, data);
    }
}
Also used : EzyCommand(com.tvd12.ezyfoxserver.client.constant.EzyCommand) EzyArray(com.tvd12.ezyfoxserver.client.entity.EzyArray)

Example 4 with EzyCommand

use of com.tvd12.ezyfoxserver.client.constant.EzyCommand in project ezyfox-server-android-client by youngmonkeys.

the class EzyTcpClient method send.

@Override
public void send(EzyCommand cmd, EzyArray data, boolean encrypted) {
    boolean shouldEncrypted = encrypted;
    if (encrypted && sessionKey == null) {
        if (config.isEnableDebug()) {
            shouldEncrypted = false;
        } else {
            throw new IllegalArgumentException("can not send command: " + cmd + " " + "you must enable SSL or enable debug mode by configuration " + "when you create the client");
        }
    }
    EzyArray array = requestSerializer.serialize(cmd, data);
    if (socketClient != null) {
        socketClient.sendMessage(array, shouldEncrypted);
        printSentData(cmd, data);
    }
}
Also used : EzyArray(com.tvd12.ezyfoxserver.client.entity.EzyArray)

Aggregations

EzyArray (com.tvd12.ezyfoxserver.client.entity.EzyArray)2 EzyCommand (com.tvd12.ezyfoxserver.client.constant.EzyCommand)1 EzyData (com.tvd12.ezyfoxserver.client.entity.EzyData)1 EzyCommand (com.tvd12.ezyfoxserver.constant.EzyCommand)1 BaseTest (com.tvd12.test.base.BaseTest)1 Test (org.testng.annotations.Test)1