org.lastbamboo.common.p2p
Class DefaultRawUdpServerDepot

java.lang.Object
  extended by org.lastbamboo.common.p2p.DefaultRawUdpServerDepot
All Implemented Interfaces:
RawUdpServerDepot, org.littleshoot.util.SessionSocketListener

public class DefaultRawUdpServerDepot
extends Object
implements RawUdpServerDepot

This class accepts incoming, typically relayed raw UDP data connections.


Constructor Summary
DefaultRawUdpServerDepot()
           
 
Method Summary
 void addError(String id, String msg)
          Adds an error.
 void addSocket(String id, Socket sock)
          Adds the specified socket to the depot.
 Collection<String> getIds()
          Get all IDs of current sessions.
 Socket getSocket(String id)
          Accessor for the Socket with the specified ID.
 void onSocket(String id, Socket sock)
           
 long read(String id, OutputStream outputStream, int length)
           
 void reconnected()
           
 org.json.simple.JSONObject toJson()
           
 void write(String id, byte[] data)
           
 long write(String id, InputStream is, long contentLength)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRawUdpServerDepot

public DefaultRawUdpServerDepot()
Method Detail

onSocket

public void onSocket(String id,
                     Socket sock)
              throws IOException
Specified by:
onSocket in interface org.littleshoot.util.SessionSocketListener
Throws:
IOException

addSocket

public void addSocket(String id,
                      Socket sock)
Description copied from interface: RawUdpServerDepot
Adds the specified socket to the depot.

Specified by:
addSocket in interface RawUdpServerDepot
Parameters:
id - The ID for the socket.
sock - The Socket to add.

getSocket

public Socket getSocket(String id)
Description copied from interface: RawUdpServerDepot
Accessor for the Socket with the specified ID.

Specified by:
getSocket in interface RawUdpServerDepot
Parameters:
id - The ID of the socket we're looking for.
Returns:
The Socket.

getIds

public Collection<String> getIds()
Description copied from interface: RawUdpServerDepot
Get all IDs of current sessions.

Specified by:
getIds in interface RawUdpServerDepot
Returns:
All IDs of current sessions.

addError

public void addError(String id,
                     String msg)
Description copied from interface: RawUdpServerDepot
Adds an error.

Specified by:
addError in interface RawUdpServerDepot
Parameters:
id - The ID for the session.
msg - The error message.

write

public long write(String id,
                  InputStream is,
                  long contentLength)
           throws IOException
Specified by:
write in interface RawUdpServerDepot
Throws:
IOException

write

public void write(String id,
                  byte[] data)
           throws IOException
Specified by:
write in interface RawUdpServerDepot
Throws:
IOException

read

public long read(String id,
                 OutputStream outputStream,
                 int length)
          throws IOException
Specified by:
read in interface RawUdpServerDepot
Throws:
IOException

toJson

public org.json.simple.JSONObject toJson()
Specified by:
toJson in interface RawUdpServerDepot

reconnected

public void reconnected()
Specified by:
reconnected in interface org.littleshoot.util.SessionSocketListener


Copyright © 2013 LittleShoot. All Rights Reserved.