Session¶
-
public class
Session¶ The class representing Carrier session conversion with friends.
Methods¶
addService¶
-
public void
addService(String service, PortForwardingProtocol protocol, String host, String port)¶ Add a new portforwarding service to session. The registered services can be used by remote peer in portforwarding request.
- Parameters
service – The new service name, should be unique in session scope
protocol – The protocol of the service
host – The host name or ip of the service
port – The port of the service
- Throws
IllegalArgumentException – IOEXException
addStream¶
-
public Stream
addStream(StreamType type, int options, StreamHandler handler)¶ Add a new stream to session. Carrier stream supports several underlying transport mechanisms: - Plain/encrypted UDP data gram protocol - Plain/encrypted TCP like reliable stream protocol - Multiplexing over UDP - Multiplexing over TCP like reliable protocol Application can use options to specify the new stream mode. Multiplexing over UDP can not provide reliable transport.
- Parameters
type – The stream type defined in StreamType
options – The stream mode options. options are constructed by a bitwise-inclusive OR of flags
handler – The Application defined inerface to StreamHandler
- Throws
IllegalArgumentException – IOEXException
- Returns
The new added carrier stream
close¶
-
public synchronized void
close()¶ Close a session to friend. All resources include streams, channels, portforwardings associated with current session will be destroyed.
removeService¶
removeStream¶
-
public void
removeStream(Stream stream)¶ Remove a stream from session.
- Parameters
stream – The Stream to be removed
- Throws
IllegalArgumentException – IOEXException
replyRequest¶
-
public void
replyRequest(int status, String reason)¶ Reply the session request from friend. This function will send a session response to friend.
- Parameters
status – The status code of the response. 0 is success, otherwise is error
reason – The error message if status is error, or null if success
- Throws
IllegalArgumentException – IOEXException
request¶
-
public void
request(SessionRequestCompleteHandler handler)¶ Send session request to the friend.
- Parameters
handler – A handler to the SessionRequestCompleteHandler to receive the session response
- Throws
IllegalArgumentException – IOEXException
start¶
-
public void
start(String sdp)¶ Begin to start a session. All streams in current session will try to connect with remote friend, The stream status will update to application by stream’s StreamHandler.
- Parameters
sdp – The remote user’s SDP. Reference: https://tools.ietf.org/html/rfc4566
- Throws
IllegalArgumentException – IOEXException