protected void checkClosed() { if( sock == null ) throw new ConnectorException( "Connection is closed:" + remoteAddress ); }
protected void checkClosed() { if( sock == null ) throw new ConnectorException( "Connection is closed:" + remoteAddress ); }
public void write( ByteBuffer data ) { checkClosed(); try { out.write(data.array(), data.position(), data.remaining()); } catch( IOException e ) { throw new ConnectorException( "Error writing to connection:" + remoteAddress, e ); } }
public void write( ByteBuffer data ) { checkClosed(); try { DatagramPacket p = new DatagramPacket( data.array(), data.position(), data.remaining(), remoteAddress ); sock.send(p); } catch( IOException e ) { throw new ConnectorException( "Error writing to connection:" + remoteAddress, e ); } } }
public void close() { checkClosed(); try { Socket temp = sock; sock = null; connected.set(false); temp.close(); } catch( IOException e ) { throw new ConnectorException( "Error closing socket for:" + remoteAddress, e ); } }
public boolean available() { checkClosed(); try { return in.available() > 0; } catch( IOException e ) { throw new ConnectorException( "Error retrieving data availability for:" + remoteAddress, e ); } }
public ByteBuffer read() { checkClosed(); try { DatagramPacket packet = new DatagramPacket( buffer, buffer.length ); sock.receive(packet); // Wrap it in a ByteBuffer for the caller return ByteBuffer.wrap( buffer, 0, packet.getLength() ); } catch( IOException e ) { if( !connected.get() ) { // Nothing to see here... just move along return null; } throw new ConnectorException( "Error reading from connection to:" + remoteAddress, e ); } }
public ByteBuffer read() { checkClosed(); try { // Read what we can int count = in.read(buffer); if( count < 0 ) { // Socket is closed close(); return null; } // Wrap it in a ByteBuffer for the caller return ByteBuffer.wrap( buffer, 0, count ); } catch( IOException e ) { if( !connected.get() ) { // Nothing to see here... just move along return null; } throw new ConnectorException( "Error reading from connection to:" + remoteAddress, 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 ); } }
protected void checkClosed() { if( sock == null ) throw new ConnectorException( "Connection is closed:" + remoteAddress ); }
protected void checkClosed() { if( sock == null ) throw new ConnectorException( "Connection is closed:" + remoteAddress ); }
protected void checkClosed() { if( sock == null ) throw new ConnectorException( "Connection is closed:" + remoteAddress ); }
protected void checkClosed() { if( sock == null ) throw new ConnectorException( "Connection is closed:" + remoteAddress ); }
public void write( ByteBuffer data ) { checkClosed(); try { DatagramPacket p = new DatagramPacket( data.array(), data.position(), data.remaining(), remoteAddress ); sock.send(p); } catch( IOException e ) { throw new ConnectorException( "Error writing to connection:" + remoteAddress, e ); } } }
public void close() { checkClosed(); try { Socket temp = sock; sock = null; connected.set(false); temp.close(); } catch( IOException e ) { throw new ConnectorException( "Error closing socket for:" + remoteAddress, e ); } }
public void write( ByteBuffer data ) { checkClosed(); try { out.write(data.array(), data.position(), data.remaining()); } catch( IOException e ) { throw new ConnectorException( "Error writing to connection:" + remoteAddress, e ); } }
public void close() { checkClosed(); try { Socket temp = sock; sock = null; connected.set(false); temp.close(); } catch( IOException e ) { throw new ConnectorException( "Error closing socket for:" + remoteAddress, e ); } }
public boolean available() { checkClosed(); try { return in.available() > 0; } catch( IOException e ) { throw new ConnectorException( "Error retrieving data availability for:" + remoteAddress, e ); } }
public void write( ByteBuffer data ) { checkClosed(); try { DatagramPacket p = new DatagramPacket( data.array(), data.position(), data.remaining(), remoteAddress ); sock.send(p); } catch( IOException e ) { throw new ConnectorException( "Error writing to connection:" + remoteAddress, e ); } } }
public void write( ByteBuffer data ) { checkClosed(); try { out.write(data.array(), data.position(), data.remaining()); } catch( IOException e ) { throw new ConnectorException( "Error writing to connection:" + remoteAddress, e ); } }