Search in sources :

Example 1 with EzySimpleBytesPackage

use of com.tvd12.ezyfoxserver.socket.EzySimpleBytesPackage in project ezyfox-server by youngmonkeys.

the class EzyStreamBytesImpl method execute.

@Override
public void execute(byte[] bytes, EzySession recipient, EzyTransportType transportType) {
    EzyStreamingApi streamingApi = server.getStreamingApi();
    EzySimpleBytesPackage pack = newPackage(bytes, transportType);
    pack.addRecipient(recipient);
    try {
        streamingApi.response(pack);
    } catch (Exception e) {
        logger.warn("send {} bytes {}, to client: {} error", bytes.length, recipient.getName(), e);
    } finally {
        pack.release();
    }
}
Also used : EzyStreamingApi(com.tvd12.ezyfoxserver.api.EzyStreamingApi) EzySimpleBytesPackage(com.tvd12.ezyfoxserver.socket.EzySimpleBytesPackage)

Example 2 with EzySimpleBytesPackage

use of com.tvd12.ezyfoxserver.socket.EzySimpleBytesPackage in project ezyfox-server by youngmonkeys.

the class EzyStreamBytesImpl method newPackage.

protected EzySimpleBytesPackage newPackage(byte[] bytes, EzyTransportType transportType) {
    EzySimpleBytesPackage pack = new EzySimpleBytesPackage();
    pack.setBytes(bytes);
    pack.setTransportType(transportType);
    return pack;
}
Also used : EzySimpleBytesPackage(com.tvd12.ezyfoxserver.socket.EzySimpleBytesPackage)

Example 3 with EzySimpleBytesPackage

use of com.tvd12.ezyfoxserver.socket.EzySimpleBytesPackage in project ezyfox-server by youngmonkeys.

the class EzyStreamBytesImpl method execute.

@Override
public void execute(byte[] bytes, Collection<EzySession> recipients, EzyTransportType transportType) {
    EzyStreamingApi streamingApi = server.getStreamingApi();
    EzySimpleBytesPackage pack = newPackage(bytes, transportType);
    pack.addRecipients(recipients);
    try {
        streamingApi.response(pack);
    } catch (Exception e) {
        logger.warn("send: {} bytes, to client: {} error", bytes.length, getRecipientsNames(recipients), e);
    } finally {
        pack.release();
    }
}
Also used : EzyStreamingApi(com.tvd12.ezyfoxserver.api.EzyStreamingApi) EzySimpleBytesPackage(com.tvd12.ezyfoxserver.socket.EzySimpleBytesPackage)

Example 4 with EzySimpleBytesPackage

use of com.tvd12.ezyfoxserver.socket.EzySimpleBytesPackage in project ezyfox-server by youngmonkeys.

the class EzySimpleBytesPackageTest method test.

@Test
public void test() {
    EzySimpleBytesPackage pack = new EzySimpleBytesPackage();
    pack.setTransportType(EzyTransportType.TCP);
    assert pack.getTransportType() == EzyTransportType.TCP;
}
Also used : EzySimpleBytesPackage(com.tvd12.ezyfoxserver.socket.EzySimpleBytesPackage) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Aggregations

EzySimpleBytesPackage (com.tvd12.ezyfoxserver.socket.EzySimpleBytesPackage)4 EzyStreamingApi (com.tvd12.ezyfoxserver.api.EzyStreamingApi)2 BaseTest (com.tvd12.test.base.BaseTest)1 Test (org.testng.annotations.Test)1