|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprotocol.RemotePeer
public class RemotePeer
Encapsulates the link between the UDP channel and a CallContext. UDP channel receives packets from all remote peers and dispatches them to particular RemotePeer handler. RemotePeer might have multiple calls in real PBX, howerever, this implementation allows only single CallContext per RemotePeer.
Field Summary | |
---|---|
private CallContext |
call
The call context |
protected java.util.Vector<byte[]> |
inboundPDUs
The queue of incoming PDUs from remote peer via our UDP channel |
private long |
lastReceiverTimestamp
The time-stamp of the last received PDU |
protected java.lang.Thread |
pduReceiverThread
The receiving process thread. |
private java.net.InetAddress |
remoteAddr
Remote IP address where to send PDUs |
private int |
remotePort
Remote UDP port where to send PDUs |
private java.lang.String |
remoteUserId
PBXClient's (chat server's) User ID of the remote peer |
private DatagramChannel |
socket
The UDP channel |
private boolean |
transmitting
Indicates whether communication with peer is active or not |
Constructor Summary | |
---|---|
RemotePeer(DatagramChannel socket,
java.lang.String remoteUserId,
java.net.InetAddress remoteAddr,
int remotePort)
Constructor for the RemotePeer object |
Method Summary | |
---|---|
void |
addIncomingPDU(byte[] data)
Adds an incoming PDUs (as bytes) to the PDUs queue. |
void |
addNewCall(CallContext call)
Adds the new (not owned) call to the peer. |
void |
cleanUp()
Stops transmitting and c cleans up resources (local and used by the calls). |
java.lang.String |
getRemoteUserId()
Returns remote name (remote userid) of the peer |
(package private) void |
parsePDU(byte[] octets)
Deals with newly received PDU octets. |
long |
receiverIdleTime()
Returns elapsed time since last received packet |
void |
run()
Manages the incoming PDUs stored in the PDUs queue. |
void |
send(OctetBuffer pdu)
Sends packet to remote peer over datagram channel |
private void |
startReceiver()
This method starts the receiver thread for inbound PDUs. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private DatagramChannel socket
private CallContext call
private java.lang.String remoteUserId
private java.net.InetAddress remoteAddr
private int remotePort
protected java.util.Vector<byte[]> inboundPDUs
protected java.lang.Thread pduReceiverThread
private volatile boolean transmitting
private long lastReceiverTimestamp
Constructor Detail |
---|
public RemotePeer(DatagramChannel socket, java.lang.String remoteUserId, java.net.InetAddress remoteAddr, int remotePort)
socket
- instance of DatagramChannel used for communicationremoteUserId
- peer's user IDremoteAddr
- peer's IP addressremotePort
- peer's UDP port listening for ours PDUsMethod Detail |
---|
public java.lang.String getRemoteUserId()
private void startReceiver()
public long receiverIdleTime()
public void addIncomingPDU(byte[] data)
data
- The PDU octetspublic void run()
run
in interface java.lang.Runnable
void parsePDU(byte[] octets)
public void addNewCall(CallContext call)
public void cleanUp()
public void send(OctetBuffer pdu)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |