public class GoogleRelayedCandidateDelegate extends Object implements MessageEventHandler, ResponseCollector
Modifier and Type | Field and Description |
---|---|
private boolean |
closed
The indicator which determines whether this instance has started
executing or has executed its
close() method. |
private static Logger |
logger
The Logger used by the
GoogleRelayedCandidateDatagramSocket class and its instances for
logging output.
|
private List<DatagramPacket> |
packetsToReceive
The DatagramPackets which are to be received through this
DatagramSocket upon calls to its
receive(DatagramPacket) method. |
private List<DatagramPacket> |
packetsToSend
The DatagramSockets which have been sent through this
DatagramSocket using its
send(DatagramPacket) method
and which are to be relayed through its associated TURN server in the
form of Send indications. |
private Thread |
sendThread
The Thread which is to send the
packetsToSend to the
associated TURN server. |
private GoogleTurnCandidateHarvest |
turnCandidateHarvest
The GoogleTurnCandidateHarvest which has harvested
#relayedCandidate . |
private String |
username
Username.
|
Constructor and Description |
---|
GoogleRelayedCandidateDelegate(GoogleTurnCandidateHarvest turnCandidateHarvest,
String username)
Initializes a new GoogleRelayedCandidateDatagramSocket instance
which is to be the socket of a specific
RelayedCandidate harvested by a specific
TurnCandidateHarvest.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this datagram socket.
|
private void |
createSendThread()
Creates
sendThread which is to send packetsToSend to
the associated TURN server. |
void |
handleMessageEvent(StunMessageEvent e)
Notifies this MessageEventHandler that a specific STUN message
has been received, parsed and is ready for delivery.
|
boolean |
processErrorOrFailure(Response response,
Request request)
Notifies this GoogleRelayedCandidateDatagramSocket that a
specific Request it has sent has either failed or received a
STUN error Response.
|
void |
processResponse(StunResponseEvent response)
Dispatch the specified response.
|
void |
processSuccess(Response response,
Request request)
Notifies this GoogleRelayedCandidateDatagramSocket that a
specific Request it has sent has received a STUN success
Response.
|
void |
processTimeout(StunTimeoutEvent event)
Notifies this collector that no response had been received after repeated
retransmissions of the original request (as described by rfc3489) and
that the request should be considered unanswered.
|
void |
receive(DatagramPacket p)
Receives a datagram packet from this socket.
|
private void |
runInSendThread()
Runs in
sendThread to send packetsToSend to the
associated TURN server. |
void |
send(DatagramPacket p)
Sends a datagram packet from this socket.
|
private static final Logger logger
private boolean closed
close()
method.private final List<DatagramPacket> packetsToReceive
receive(DatagramPacket)
method. They have been received from the
TURN server in the form of Data indications.private final List<DatagramPacket> packetsToSend
send(DatagramPacket)
method
and which are to be relayed through its associated TURN server in the
form of Send indications.private Thread sendThread
packetsToSend
to the
associated TURN server.private final GoogleTurnCandidateHarvest turnCandidateHarvest
#relayedCandidate
.private final String username
public GoogleRelayedCandidateDelegate(GoogleTurnCandidateHarvest turnCandidateHarvest, String username) throws SocketException
turnCandidateHarvest
- the TurnCandidateHarvest which has
harvested relayedCandidateusername
- usernameSocketException
- if anything goes wrong while initializing the new
GoogleRelayedCandidateDatagramSocket instancepublic void close()
DatagramSocket.close()
public void handleMessageEvent(StunMessageEvent e)
handleMessageEvent
in interface MessageEventHandler
e
- a StunMessageEvent which encapsulates the received STUN
messagepublic boolean processErrorOrFailure(Response response, Request request)
response
- the Response which responds to requestrequest
- the Request sent by this instance to which
response respondspublic void processSuccess(Response response, Request request)
response
- the Response which responds to requestrequest
- the Request sent by this instance to which
response respondspublic void processResponse(StunResponseEvent response)
processResponse
in interface ResponseCollector
response
- the response to dispatch.public void processTimeout(StunTimeoutEvent event)
processTimeout
in interface ResponseCollector
event
- the StunTimeoutEvent containing a reference to the
transaction that has just failed.public void receive(DatagramPacket p) throws IOException
p
- the DatagramPacket into which to place the incoming
dataIOException
- if an I/O error occursDatagramSocket.receive(DatagramPacket)
public void send(DatagramPacket p) throws IOException
p
- the DatagramPacket to be sentIOException
- if an I/O error occursDatagramSocket.send(DatagramPacket)
private void createSendThread()
sendThread
which is to send packetsToSend
to
the associated TURN server.private void runInSendThread()
sendThread
to send packetsToSend
to the
associated TURN server.Copyright © 2018. All rights reserved.