Search in sources :

Example 6 with EzySimpleSocketStream

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

the class EzySimpleWsHandlerGroup method handleReceivedBytes.

private void handleReceivedBytes(byte[] bytes, int offset, int len) {
    try {
        if (len <= 1) {
            return;
        }
        byte headerByte = bytes[offset];
        boolean isRawBytes = EzyMessageHeaderReader.readRawBytes(headerByte);
        if (isRawBytes) {
            boolean sessionStreamingEnable = session.isStreamingEnable();
            if (!streamingEnable || !sessionStreamingEnable) {
                return;
            }
            byte[] rawBytes = EzyBytes.copy(bytes, offset, len);
            EzySocketStream stream = new EzySimpleSocketStream(session, rawBytes);
            streamQueue.add(stream);
        } else {
            int newLen = len - 1;
            int newOffset = offset + 1;
            byte[] messageBytes = EzyBytes.copy(bytes, newOffset, newLen);
            handleReceivedBytes(messageBytes);
        }
    } catch (Throwable throwable) {
        fireExceptionCaught(throwable);
    }
}
Also used : EzySimpleSocketStream(com.tvd12.ezyfoxserver.socket.EzySimpleSocketStream) EzySocketStream(com.tvd12.ezyfoxserver.socket.EzySocketStream)

Aggregations

Test (org.testng.annotations.Test)4 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)3 EzySimpleSocketStream (com.tvd12.ezyfoxserver.socket.EzySimpleSocketStream)3 EzySocketStream (com.tvd12.ezyfoxserver.socket.EzySocketStream)2 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)1 BaseTest (com.tvd12.test.base.BaseTest)1