コード例 #1
0
 /**
  * Writes an the {@link Events#DISCONNECT} to the client, flushes all the pending writes and
  * closes the channel.
  */
 @Override
 public void close() {
   LOG.debug("Going to close tcp connection in class: {}", this.getClass().getName());
   Event event = Events.event(null, Events.DISCONNECT);
   if (channel.isActive()) {
     channel.write(event).addListener(ChannelFutureListener.CLOSE);
   } else {
     channel.close();
     LOG.trace("Unable to write the Event {} with type {} to socket", event, event.getType());
   }
 }
コード例 #2
0
 @Test
 public void verifyAMF3BinaryEncodingAndDecoding() throws InterruptedException {
   EmbeddedChannel outChannel =
       new EmbeddedChannel(
           amf3Protocol.getLengthFieldPrepender(), amf3Protocol.getJavaObjectToAMF3Encoder());
   EmbeddedChannel inChannel =
       new EmbeddedChannel(frameDecoder, amf3Protocol.createAMF3ToJavaObjectDecoder());
   Event event = Events.event(playerStats, Events.SESSION_MESSAGE);
   outChannel.writeOutbound(event);
   assertTrue(outChannel.finish());
   ByteBuf buffer = (ByteBuf) outChannel.readOutbound();
   assertNotNull(buffer);
   inChannel.writeInbound(buffer);
   // assertTrue(inChannel.finish());
   //		Event decoded = (Event)inChannel.readInbound();
   //		assertTrue(decoded.getType() == Events.SESSION_MESSAGE);
   //		PlayerStats playerStats = (PlayerStats) decoded.getSource();
   //		assertEquals(playerStats, this.playerStats);
 }