public static EndpointEvent createRemove( Kernel source, Endpoint p ) { return new EndpointEvent( source, p, Type.REMOVE ); }
protected Endpoint getEndpoint( SocketAddress address, boolean create ) { UdpEndpoint p = socketEndpoints.get(address); if( p == null && create ) { p = new UdpEndpoint( this, nextEndpointId(), address, thread.getSocket() ); socketEndpoints.put( address, p ); // Add an event for it. addEvent( EndpointEvent.createAdd( this, p ) ); } return p; }
protected void removeEndpoint( NioEndpoint p, SocketChannel c ) { endpoints.remove( p.getId() ); log.log( Level.FINE, "Endpoints size:{0}", endpoints.size() ); // Enqueue an endpoint event for the listeners addEvent( EndpointEvent.createRemove( this, p ) ); wakeupReader(); }
protected void createAndDispatch( EndpointEvent event ) { // Only need to tell the server about disconnects if( event.getType() == EndpointEvent.Type.REMOVE ) { connectionClosed( event.getEndpoint() ); } }
protected void flushEvents() { EndpointEvent event; while( (event = kernel.nextEvent()) != null ) { try { createAndDispatch( event ); } catch( Exception e ) { reportError(event.getEndpoint(), event, e); } } }
protected void createAndDispatch( EndpointEvent event ) { // Only need to tell the server about disconnects if( event.getType() == EndpointEvent.Type.REMOVE ) { connectionClosed( event.getEndpoint() ); } }
protected void flushEvents() { EndpointEvent event; while( (event = kernel.nextEvent()) != null ) { try { createAndDispatch( event ); } catch( Exception e ) { reportError(event.getEndpoint(), event, e); } } }
protected void createAndDispatch( EndpointEvent event ) { // Only need to tell the server about disconnects if( event.getType() == EndpointEvent.Type.REMOVE ) { connectionClosed( event.getEndpoint() ); } }
public static EndpointEvent createAdd( Kernel source, Endpoint p ) { return new EndpointEvent( source, p, Type.ADD ); }
/** * Called by the endpoints when they need to be closed. */ protected void closeEndpoint( UdpEndpoint p ) throws IOException { // Just book-keeping to do here. if( socketEndpoints.remove( p.getRemoteAddress() ) == null ) return; log.log( Level.FINE, "Closing endpoint:{0}.", p ); log.log( Level.FINE, "Socket endpoints size:{0}", socketEndpoints.size() ); addEvent( EndpointEvent.createRemove( this, p ) ); wakeupReader(); }
protected NioEndpoint addEndpoint( SocketChannel c ) { // Note: we purposely do NOT put the key in the endpoint. // SelectionKeys are dangerous outside the selector thread // and this is safer. NioEndpoint p = new NioEndpoint( this, nextEndpointId(), c ); endpoints.put( p.getId(), p ); // Enqueue an endpoint event for the listeners addEvent( EndpointEvent.createAdd( this, p ) ); return p; }
protected void flushEvents() { EndpointEvent event; while( (event = kernel.nextEvent()) != null ) { try { createAndDispatch( event ); } catch( Exception e ) { reportError(event.getEndpoint(), event, e); } } }
public static EndpointEvent createRemove( Kernel source, Endpoint p ) { return new EndpointEvent( source, p, Type.REMOVE ); }
/** * Called by the endpoints when they need to be closed. */ protected void closeEndpoint( UdpEndpoint p ) throws IOException { log.log( Level.INFO, "Closing endpoint:{0}.", p ); // Just book-keeping to do here. socketEndpoints.remove( p.getRemoteAddress() ); addEvent( EndpointEvent.createRemove( this, p ) ); }
protected Endpoint getEndpoint( SocketAddress address, boolean create ) { UdpEndpoint p = socketEndpoints.get(address); if( p == null && create ) { p = new UdpEndpoint( this, nextEndpointId(), address, thread.getSocket() ); socketEndpoints.put( address, p ); // Add an event for it. addEvent( EndpointEvent.createAdd( this, p ) ); } return p; }
public static EndpointEvent createAdd( Kernel source, Endpoint p ) { return new EndpointEvent( source, p, Type.ADD ); }
/** * Called by the endpoints when they need to be closed. */ protected void closeEndpoint( UdpEndpoint p ) throws IOException { // Just book-keeping to do here. if( socketEndpoints.remove( p.getRemoteAddress() ) == null ) return; log.log( Level.FINE, "Closing endpoint:{0}.", p ); log.log( Level.FINE, "Socket endpoints size:{0}", socketEndpoints.size() ); addEvent( EndpointEvent.createRemove( this, p ) ); wakeupReader(); }
protected Endpoint getEndpoint( SocketAddress address, boolean create ) { UdpEndpoint p = socketEndpoints.get(address); if( p == null && create ) { p = new UdpEndpoint( this, nextEndpointId(), address, thread.getSocket() ); socketEndpoints.put( address, p ); // Add an event for it. addEvent( EndpointEvent.createAdd( this, p ) ); } return p; }
public static EndpointEvent createAdd( Kernel source, Endpoint p ) { return new EndpointEvent( source, p, Type.ADD ); }
protected void removeEndpoint( NioEndpoint p, SocketChannel c ) { endpoints.remove( p.getId() ); log.log( Level.FINE, "Endpoints size:{0}", endpoints.size() ); // Enqueue an endpoint event for the listeners addEvent( EndpointEvent.createRemove( this, p ) ); wakeupReader(); }