|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.lastbamboo.common.turn.server.TurnClientImpl
public final class TurnClientImpl
Default TURN client implementation. Starts the server on behalf of the TURN client and keeps track of remote hosts that have permission to send incoming data to this client.
Note that this class does not implement CloseListener because
doing so would require us to keep track of a separate data structure of
"canceled" connections. Instead, we simply allow the write attempt to
throw an IOException, allowing the caller to respond with
"Send Error Response" messages to the TURN client as appropriate.
Note that the lifetime of TURN allocations is handled externally according to how the connection has been idle.
We deviate from the TURN spec here because it just seems to make sense to only close TURN sessions when there's been no data, not after fixed periods regardless of whether there's data or not.
| Constructor Summary | |
|---|---|
TurnClientImpl(InetAddress publicAddress,
org.littleshoot.mina.common.IoSession ioSession)
Creates a new TURN client abstraction for the specified TURN client address and port. |
|
| Method Summary | |
|---|---|
void |
addConnection(org.littleshoot.mina.common.IoSession session)
Adds the specified connection for this TURN client. |
void |
close()
Closes the client and all associated connections. |
org.littleshoot.mina.common.IoSession |
getIoSession()
Accessor for the handler for reading and writing data with this client. |
InetSocketAddress |
getMappedAddress()
Accessor for the MAPPED ADDRESS, otherwise known as the server reflexive address. |
int |
getNumConnections()
Returns the number of connections for this TURN client. |
InetSocketAddress |
getRelayAddress()
Accessor for the IP and port this server has allocated on behalf of the TURN client. |
void |
handleConnect(InetSocketAddress remoteAddress)
Tells the client to appropriately handle a connect request to the specified remote host. |
boolean |
hasActiveDestination()
Returns whether or not the TURN client has set its "active destination" turning off TURN messaging on that connection. |
boolean |
hasIncomingPermission(org.littleshoot.mina.common.IoSession session)
Returns whether or not the remote host who created the specified session has permission to open a connection to this TURN client. |
void |
removeConnection(org.littleshoot.mina.common.IoSession session)
Removes the connection. |
void |
startServer()
Starts the separate server running on the client's allocated address for accepting connections from remote hosts. |
boolean |
write(InetSocketAddress remoteAddress,
org.littleshoot.mina.common.ByteBuffer data)
Writes data from this TURN client to the specified remote address. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TurnClientImpl(InetAddress publicAddress,
org.littleshoot.mina.common.IoSession ioSession)
publicAddress - The public address of the server. The port will
be determined later using an ephemeral port when we bind.ioSession - The handler for writing data back to the TURN client.| Method Detail |
|---|
public void startServer()
TurnClient
startServer in interface TurnClient
public boolean write(InetSocketAddress remoteAddress,
org.littleshoot.mina.common.ByteBuffer data)
TurnClient
write in interface TurnClientremoteAddress - The IP address and port of the remote host to send
data to.data - The data to send the remote host.
true if the data was send to an existing binding.
Otherwise, this returns false to indicate that there was
no existing matching 5-tuple for the remote host and that we're
attempting to connect to that remote host.public void handleConnect(InetSocketAddress remoteAddress)
TurnClient
handleConnect in interface TurnClientremoteAddress - The address to handle.public InetSocketAddress getRelayAddress()
TurnClient
getRelayAddress in interface TurnClientpublic InetSocketAddress getMappedAddress()
TurnClient
getMappedAddress in interface TurnClientpublic void close()
TurnClient
close in interface TurnClientpublic org.littleshoot.mina.common.IoSession getIoSession()
TurnClient
getIoSession in interface TurnClientpublic boolean hasActiveDestination()
TurnClient
hasActiveDestination in interface TurnClienttrue if the client has set the active destination,
otherwise false.public void removeConnection(org.littleshoot.mina.common.IoSession session)
TurnClient
removeConnection in interface TurnClientsession - The class for reading and writing data with the
remote host.public void addConnection(org.littleshoot.mina.common.IoSession session)
TurnClient
addConnection in interface TurnClientsession - The class for reading and writing data with the
remote host.public boolean hasIncomingPermission(org.littleshoot.mina.common.IoSession session)
TurnClient
hasIncomingPermission in interface TurnClientsession - The connection from the remote host.
true if the remote host has permission to connect
to the TURN client, otherwise false.public int getNumConnections()
getNumConnections in interface TurnClient
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||