LimeWire Consolidated API

org.limewire.rudp
Class UDPMultiplexor

java.lang.Object
  extended by java.nio.channels.Selector
      extended by java.nio.channels.spi.AbstractSelector
          extended by org.limewire.rudp.UDPMultiplexor

public class UDPMultiplexor
extends AbstractSelector

Manages the assignment of connection IDs and the routing of RUDPMessages.


Field Summary
static byte UNASSIGNED_SLOT
          The 0 slot is for incoming new connections so it is not assigned
 
Method Summary
protected  void implCloseSelector()
           
 boolean isConnectedTo(InetAddress host)
          Determines if we're connected to the given host.
 Set<SelectionKey> keys()
          Returns all SelectionKeys this Selector is currently in control of.
protected  SelectionKey register(AbstractSelectableChannel ch, int ops, Object att)
          Registers a new channel with this Selector.
 void routeMessage(RUDPMessage msg, InetSocketAddress addr)
          Route a message to the UDPConnectionProcessor identified via the message's connection ID.
 int select()
           
 int select(long timeout)
           
 Set<SelectionKey> selectedKeys()
           
 int selectNow()
          Polls through all available channels and returns those that are ready.
 Selector wakeup()
           
 
Methods inherited from class java.nio.channels.spi.AbstractSelector
begin, cancelledKeys, close, deregister, end, isOpen, provider
 
Methods inherited from class java.nio.channels.Selector
open
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNASSIGNED_SLOT

public static final byte UNASSIGNED_SLOT
The 0 slot is for incoming new connections so it is not assigned

See Also:
Constant Field Values
Method Detail

isConnectedTo

public boolean isConnectedTo(InetAddress host)
Determines if we're connected to the given host.


routeMessage

public void routeMessage(RUDPMessage msg,
                         InetSocketAddress addr)
Route a message to the UDPConnectionProcessor identified via the message's connection ID. Notifies the provided listener (if any) if the channel is ready to produce events.


implCloseSelector

protected void implCloseSelector()
                          throws IOException
Specified by:
implCloseSelector in class AbstractSelector
Throws:
IOException

register

protected SelectionKey register(AbstractSelectableChannel ch,
                                int ops,
                                Object att)
Registers a new channel with this Selector. If we've already stored over the limit of channels, this will store the channel in a temporary list to be cancelled on the next selection.

Specified by:
register in class AbstractSelector

keys

public Set<SelectionKey> keys()
Returns all SelectionKeys this Selector is currently in control of.

Specified by:
keys in class Selector

select

public int select()
           throws IOException
Specified by:
select in class Selector
Throws:
IOException

select

public int select(long timeout)
           throws IOException
Specified by:
select in class Selector
Throws:
IOException

selectedKeys

public Set<SelectionKey> selectedKeys()
Specified by:
selectedKeys in class Selector

selectNow

public int selectNow()
              throws IOException
Polls through all available channels and returns those that are ready.

Specified by:
selectNow in class Selector
Throws:
IOException

wakeup

public Selector wakeup()
Specified by:
wakeup in class Selector

LimeWire Consolidated API

Copyright © 2009. All Rights Reserved.