Search in sources :

Example 1 with EzySimplePacket

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

the class EzyAbstractResponseApi method createPacket.

protected EzySimplePacket createPacket(Object bytes, EzyPackage pack) {
    EzySimplePacket packet = new EzySimplePacket();
    packet.setTransportType(pack.getTransportType());
    packet.setData(bytes);
    return packet;
}
Also used : EzySimplePacket(com.tvd12.ezyfoxserver.socket.EzySimplePacket)

Example 2 with EzySimplePacket

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

the class EzyWsResponseApi method createPacket.

@Override
protected EzySimplePacket createPacket(Object bytes, EzyPackage pack) {
    EzySimplePacket packet = super.createPacket(bytes, pack);
    packet.setBinary(false);
    return packet;
}
Also used : EzySimplePacket(com.tvd12.ezyfoxserver.socket.EzySimplePacket)

Example 3 with EzySimplePacket

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

the class EzyPacketTest method test.

@Test
public void test() {
    EzyPacket packet = new EzySimplePacket();
    packet.setFragment(new byte[] { 1, 2, 3 });
    long start = System.currentTimeMillis();
    for (int i = 0; i < 1000000; ++i) {
        packet.getSize();
    }
    long offset = System.currentTimeMillis() - start;
    System.out.println(offset);
}
Also used : EzyPacket(com.tvd12.ezyfoxserver.socket.EzyPacket) EzySimplePacket(com.tvd12.ezyfoxserver.socket.EzySimplePacket) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 4 with EzySimplePacket

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

the class EzySocketWriterTest method test.

@Test
public void test() throws Exception {
    EzySessionTicketsQueue sessionTicketsQueue = new EzyBlockingSessionTicketsQueue();
    EzySocketWriterGroupFetcher writerGroupFetcher = mock(EzySocketWriterGroupFetcher.class);
    EzySocketWriterGroup writerGroup = mock(EzySocketWriterGroup.class);
    when(writerGroupFetcher.getWriterGroup(any(EzySession.class))).thenReturn(writerGroup);
    EzySocketWriter socketWriter = new EzySocketWriter();
    socketWriter.setSessionTicketsQueue(sessionTicketsQueue);
    socketWriter.setWriterGroupFetcher(writerGroupFetcher);
    EzyPacketQueue packetQueue = new EzyNonBlockingPacketQueue();
    EzyPacket packet = new EzySimplePacket();
    packetQueue.add(packet);
    packetQueue.add(packet);
    EzyAbstractSession session = spy(EzyAbstractSession.class);
    session.setActivated(true);
    session.setSessionTicketsQueue(sessionTicketsQueue);
    session.setPacketQueue(packetQueue);
    sessionTicketsQueue.add(session);
    socketWriter.handleEvent();
    packet.release();
    socketWriter.handleEvent();
    socketWriter.destroy();
}
Also used : EzyAbstractSession(com.tvd12.ezyfoxserver.entity.EzyAbstractSession) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 5 with EzySimplePacket

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

the class EzyAbstractStreamingApi method createPacket.

private EzyPacket createPacket(byte[] bytes, EzyBytesPackage pack) {
    EzySimplePacket packet = new EzySimplePacket();
    packet.setTransportType(pack.getTransportType());
    packet.setData(bytes);
    return packet;
}
Also used : EzySimplePacket(com.tvd12.ezyfoxserver.socket.EzySimplePacket)

Aggregations

Test (org.testng.annotations.Test)8 BaseTest (com.tvd12.test.base.BaseTest)7 EzySimplePacket (com.tvd12.ezyfoxserver.socket.EzySimplePacket)5 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)4 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)4 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)4 EzyNioSession (com.tvd12.ezyfoxserver.nio.entity.EzyNioSession)4 EzyHandlerGroupBuilderFactory (com.tvd12.ezyfoxserver.nio.factory.EzyHandlerGroupBuilderFactory)4 EzySimpleSessionTokenGenerator (com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator)4 EzySimpleSessionManagementSetting (com.tvd12.ezyfoxserver.setting.EzySimpleSessionManagementSetting)4 EzySimpleSettings (com.tvd12.ezyfoxserver.setting.EzySimpleSettings)4 EzySimpleStreamingSetting (com.tvd12.ezyfoxserver.setting.EzySimpleStreamingSetting)4 EzySimpleStatistics (com.tvd12.ezyfoxserver.statistics.EzySimpleStatistics)4 EzyStatistics (com.tvd12.ezyfoxserver.statistics.EzyStatistics)4 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)4 ByteBuffer (java.nio.ByteBuffer)4 ExecutorService (java.util.concurrent.ExecutorService)4 EzySimpleNioHandlerGroup (com.tvd12.ezyfoxserver.nio.handler.EzySimpleNioHandlerGroup)3 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)2 EzyController (com.tvd12.ezyfoxserver.controller.EzyController)1