use of com.tvd12.ezyfoxserver.socket.EzySimpleSocketStream in project ezyfox-server by youngmonkeys.
the class EzySimpleNioHandlerGroup method handleReceivedMessage.
private void handleReceivedMessage(EzyMessage message) {
try {
EzyMessageHeader header = message.getHeader();
if (header.isRawBytes()) {
boolean sessionStreamingEnable = session.isStreamingEnable();
if (!streamingEnable || !sessionStreamingEnable) {
return;
}
byte[] rawBytes = message.getContent();
EzySocketStream stream = new EzySimpleSocketStream(session, rawBytes);
streamQueue.add(stream);
} else {
Object data = decodeMessage(message);
int dataSize = message.getByteCount();
handleReceivedData(data, dataSize);
}
} catch (Exception e) {
fireExceptionCaught(e);
} finally {
executeAddReadBytes(message.getByteCount());
}
}
use of com.tvd12.ezyfoxserver.socket.EzySimpleSocketStream in project ezyfox-server by youngmonkeys.
the class EzySocketStreamHandlerTest method test.
@Test
public void test() {
EzySocketStreamHandler handler = new EzySocketStreamHandler();
EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
EzySocketDataHandlerGroup dataHandlerGroup = mock(EzySocketDataHandlerGroup.class);
when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenReturn(dataHandlerGroup);
EzySocketStreamQueue streamQueue = new EzyBlockingSocketStreamQueue();
EzySession session = spy(EzyAbstractSession.class);
EzySocketStream stream = new EzySimpleSocketStream(session, new byte[0]);
streamQueue.add(stream);
handler.setStreamQueue(streamQueue);
handler.setDataHandlerGroupFetcher(dataHandlerGroupFetcher);
handler.handleEvent();
handler.destroy();
}
use of com.tvd12.ezyfoxserver.socket.EzySimpleSocketStream in project ezyfox-server by youngmonkeys.
the class EzySocketStreamHandlerTest method hasNoHandlerGroupCaseTest.
@Test
public void hasNoHandlerGroupCaseTest() {
EzySocketStreamHandler handler = new EzySocketStreamHandler();
EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenReturn(null);
EzySocketStreamQueue streamQueue = new EzyBlockingSocketStreamQueue();
EzySession session = spy(EzyAbstractSession.class);
EzySocketStream stream = new EzySimpleSocketStream(session, new byte[0]);
streamQueue.add(stream);
handler.setStreamQueue(streamQueue);
handler.setDataHandlerGroupFetcher(dataHandlerGroupFetcher);
handler.handleEvent();
}
use of com.tvd12.ezyfoxserver.socket.EzySimpleSocketStream in project ezyfox-server by youngmonkeys.
the class EzySocketStreamHandlerTest method doProcessStreamQueueExceptionCaseTest.
@Test
public void doProcessStreamQueueExceptionCaseTest() {
EzySocketStreamHandler handler = new EzySocketStreamHandler();
EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenThrow(new IllegalArgumentException());
EzySocketStreamQueue streamQueue = new EzyBlockingSocketStreamQueue();
EzySession session = spy(EzyAbstractSession.class);
EzySocketStream stream = new EzySimpleSocketStream(session, new byte[0]);
streamQueue.add(stream);
handler.setStreamQueue(streamQueue);
handler.setDataHandlerGroupFetcher(dataHandlerGroupFetcher);
handler.handleEvent();
}
use of com.tvd12.ezyfoxserver.socket.EzySimpleSocketStream in project ezyfox-server by youngmonkeys.
the class EzySimpleSocketStreamTest method test.
@Test
public void test() {
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleSocketStream stream = new EzySimpleSocketStream(session, new byte[0]);
System.out.println(stream.getTimestamp());
}
Aggregations