public void send ( Packet packet ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "send packet: {}" , packet ) ; } // no handshake flag, queue the packet if ( session . containsAttribute ( Constants . HANDSHAKE_COMPLETE ) ) { try { // clear any queued items first queue . forEach ( entry -> { session . write ( entry ) ; queue . remove ( entry ) ; } ) ; } catch ( Exception e ) { log . warn ( "Exception draining queued packets on session: {}" , session . getId ( ) , e ) ; } // process the incoming packet session . write ( packet ) ; } else { if ( handshakeWriteFuture != null ) { log . warn ( "Handshake is not complete yet on session: {} written? {}" , session . getId ( ) , handshakeWriteFuture . isWritten ( ) , handshakeWriteFuture . getException ( ) ) ; } else { log . warn ( "Handshake is not complete yet on session: {}" , session . getId ( ) ) ; } // not queuing pings MessageType type = packet . getType ( ) ; if ( type != MessageType . PING && type != MessageType . PONG ) { log . info ( "Placing {} message in session: {} queue" , type , session . getId ( ) ) ; queue . offer ( packet ) ; } } }
Sends WebSocket packet to the client .