use of com.tvd12.ezyfoxserver.socket.EzySocketStream in project ezyfox-server by youngmonkeys.
the class EzyBlockingSocketStreamQueueTest method test.
@Test
public void test() {
EzyBlockingSocketStreamQueue queue = new EzyBlockingSocketStreamQueue(2);
EzySocketStream stream = mock(EzySocketStream.class);
assert queue.isEmpty();
assert queue.add(stream);
assert !queue.isFull();
assert !queue.isEmpty();
assert queue.add(stream);
assert queue.isFull();
assert !queue.add(stream);
queue.remove(stream);
assert queue.size() == 1;
}
use of com.tvd12.ezyfoxserver.socket.EzySocketStream 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);
}
}
Aggregations