protected MessageProtocol getMessageBuffer( Endpoint p ) { if( !reliable ) { // Since UDP comes in packets and they aren't split // up, there is no reason to buffer. In fact, there would // be a down side because there is no way for us to reliably // clean these up later since we'd create another one for // any random UDP packet that comes to the port. return new MessageProtocol(); } else { // See if we already have one MessageProtocol result = messageBuffers.get(p); if( result == null ) { result = new MessageProtocol(); messageBuffers.put(p, result); } return result; } }
public void run() { MessageProtocol protocol = new MessageProtocol(); try { while( go.get() ) { ByteBuffer buffer = connector.read(); if( buffer == null ) { if( go.get() ) { throw new ConnectorException( "Connector closed." ); } else { // Just dump out because a null buffer is expected // from a closed/closing connector break; } } protocol.addBuffer( buffer ); Message m = null; while( (m = protocol.getMessage()) != null ) { m.setReliable( reliable ); dispatch( m ); } } } catch( Exception e ) { handleError( e ); } }
protected MessageProtocol getMessageBuffer( Endpoint p ) { if( !reliable ) { // Since UDP comes in packets and they aren't split // up, there is no reason to buffer. In fact, there would // be a down side because there is no way for us to reliably // clean these up later since we'd create another one for // any random UDP packet that comes to the port. return new MessageProtocol(); } else { // See if we already have one MessageProtocol result = messageBuffers.get(p); if( result == null ) { result = new MessageProtocol(); messageBuffers.put(p, result); } return result; } }
protected MessageProtocol getMessageBuffer( Endpoint p ) { if( !reliable ) { // Since UDP comes in packets and they aren't split // up, there is no reason to buffer. In fact, there would // be a down side because there is no way for us to reliably // clean these up later since we'd create another one for // any random UDP packet that comes to the port. return new MessageProtocol(); } else { // See if we already have one MessageProtocol result = messageBuffers.get(p); if( result == null ) { result = new MessageProtocol(); messageBuffers.put(p, result); } return result; } }
public void run() { MessageProtocol protocol = new MessageProtocol(); try { while( go.get() ) { ByteBuffer buffer = connector.read(); if( buffer == null ) { if( go.get() ) { throw new ConnectorException( "Connector closed." ); } else { // Just dump out because a null buffer is expected // from a closed/closing connector break; } } protocol.addBuffer( buffer ); Message m = null; while( (m = protocol.getMessage()) != null ) { m.setReliable( reliable ); dispatch( m ); } } } catch( Exception e ) { handleError( e ); } }
public void run() { MessageProtocol protocol = new MessageProtocol(); try { while( go.get() ) { ByteBuffer buffer = connector.read(); if( buffer == null ) { if( go.get() ) { throw new ConnectorException( "Connector closed." ); } else { // Just dump out because a null buffer is expected // from a closed/closing connector break; } } protocol.addBuffer( buffer ); Message m = null; while( (m = protocol.getMessage()) != null ) { m.setReliable( reliable ); dispatch( m ); } } } catch( Exception e ) { handleError( e ); } }