org.lastbamboo.common.p2p
Class DefaultTcpUdpSocket

java.lang.Object
  extended by org.lastbamboo.common.p2p.DefaultTcpUdpSocket
All Implemented Interfaces:
org.lastbamboo.common.offer.answer.OfferAnswerListener<Socket>, org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener, TcpUdpSocket<Socket>, org.littleshoot.util.KeyStorage

public class DefaultTcpUdpSocket
extends Object
implements TcpUdpSocket<Socket>, org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener, org.lastbamboo.common.offer.answer.OfferAnswerListener<Socket>, org.littleshoot.util.KeyStorage

Class for creating sockets that can be created using either a TCP or a reliable UDP connection, depending on which successfully connects first.


Constructor Summary
DefaultTcpUdpSocket(org.lastbamboo.common.offer.answer.Offerer offerer, org.lastbamboo.common.offer.answer.OfferAnswerFactory<Socket> offerAnswerFactory, int relayWaitTime, org.lastbamboo.common.offer.answer.IceMediaStreamDesc desc)
          Creates a new reliable TCP or UDP socket.
DefaultTcpUdpSocket(org.lastbamboo.common.offer.answer.Offerer offerer, org.lastbamboo.common.offer.answer.OfferAnswerFactory<Socket> offerAnswerFactory, int relayWaitTime, long offerTimeoutTime, org.lastbamboo.common.offer.answer.IceMediaStreamDesc desc)
           
 
Method Summary
 byte[] getReadKey()
           
 byte[] getWriteKey()
           
 Socket newSocket(URI uri)
          Creates a new socket.
 void onOfferAnswerFailed(org.lastbamboo.common.offer.answer.OfferAnswer offerAnswer)
           
 void onTcpSocket(Socket sock)
           
 void onTransactionFailed(org.lastbamboo.common.offer.answer.OfferAnswerMessage response)
           
 void onTransactionSucceeded(org.lastbamboo.common.offer.answer.OfferAnswerMessage response)
           
 void onUdpSocket(Socket sock)
           
 void setReadKey(byte[] key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTcpUdpSocket

public DefaultTcpUdpSocket(org.lastbamboo.common.offer.answer.Offerer offerer,
                           org.lastbamboo.common.offer.answer.OfferAnswerFactory<Socket> offerAnswerFactory,
                           int relayWaitTime,
                           org.lastbamboo.common.offer.answer.IceMediaStreamDesc desc)
                    throws IOException
Creates a new reliable TCP or UDP socket.

Parameters:
offerer - The client connection to the P2P signaling server.
offerAnswerFactory - The class for creating new offers and answers.
relayWaitTime - The number of seconds to wait before using the relay.
Throws:
IOException - If there's an error connecting.

DefaultTcpUdpSocket

public DefaultTcpUdpSocket(org.lastbamboo.common.offer.answer.Offerer offerer,
                           org.lastbamboo.common.offer.answer.OfferAnswerFactory<Socket> offerAnswerFactory,
                           int relayWaitTime,
                           long offerTimeoutTime,
                           org.lastbamboo.common.offer.answer.IceMediaStreamDesc desc)
                    throws IOException
Throws:
IOException
Method Detail

newSocket

public Socket newSocket(URI uri)
                 throws IOException,
                        org.lastbamboo.common.offer.answer.NoAnswerException
Description copied from interface: TcpUdpSocket
Creates a new socket.

Specified by:
newSocket in interface TcpUdpSocket<Socket>
Parameters:
uri - The URI to create a socket from. This could be a SIP URI, for example.
Returns:
The new socket.
Throws:
IOException - If there's an IO error creating the socket.
org.lastbamboo.common.offer.answer.NoAnswerException - If the answerer doesn't reply.

onTransactionSucceeded

public void onTransactionSucceeded(org.lastbamboo.common.offer.answer.OfferAnswerMessage response)
Specified by:
onTransactionSucceeded in interface org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener

onTransactionFailed

public void onTransactionFailed(org.lastbamboo.common.offer.answer.OfferAnswerMessage response)
Specified by:
onTransactionFailed in interface org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener

onTcpSocket

public void onTcpSocket(Socket sock)
Specified by:
onTcpSocket in interface org.lastbamboo.common.offer.answer.OfferAnswerListener<Socket>

onUdpSocket

public void onUdpSocket(Socket sock)
Specified by:
onUdpSocket in interface org.lastbamboo.common.offer.answer.OfferAnswerListener<Socket>

onOfferAnswerFailed

public void onOfferAnswerFailed(org.lastbamboo.common.offer.answer.OfferAnswer offerAnswer)
Specified by:
onOfferAnswerFailed in interface org.lastbamboo.common.offer.answer.OfferAnswerListener<Socket>

getWriteKey

public byte[] getWriteKey()
Specified by:
getWriteKey in interface org.littleshoot.util.KeyStorage

getReadKey

public byte[] getReadKey()
Specified by:
getReadKey in interface org.littleshoot.util.KeyStorage

setReadKey

public void setReadKey(byte[] key)
Specified by:
setReadKey in interface org.littleshoot.util.KeyStorage


Copyright © 2013 LittleShoot. All Rights Reserved.