1.0.6 • Published 3 years ago

@elastosfoundation/elastos-cordova-plugin-carrier v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

title: Carrier

description: The carrier javascript API.

elastos-cordova-plugin-carrier

This plugin defines a global cordova.carrierPlugin object, which provides an API for carrier library.

Although in the global scope, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(carrierPlugin);
}

Installation

The plugins field of dapp manifest.json adds Carrier values, such as "plugins": ["XXXX", "Carrier", "XXXX"]

Supported Platforms

  • Android
  • iOS

API Reference

Modules

Classes

Typedefs

carrierPlugin

carrierPlugin.ConnectionStatus : enum

Carrier node connection status to the carrier network.

Kind: instance enum of carrierPlugin Properties

NameTypeDefaultDescription
CONNECTEDnumber0Carrier node connected to the carrier network.
DISCONNECTEDnumber1There is no connection to the carrier network.

carrierPlugin.PresenceStatus : enum

Carrier node presence status.

Kind: instance enum of carrierPlugin Properties

NameTypeDefaultDescription
NONEnumber0Carrier node is online and available.
AWAYnumber1Carrier node is being away.
BUSYnumber2Carrier node is being busy.

carrierPlugin.StreamType : enum

Carrier stream type. Reference: https://tools.ietf.org/html/rfc4566#section-5.14 https://tools.ietf.org/html/rfc4566#section-8

Kind: instance enum of carrierPlugin Properties

NameTypeDefaultDescription
AUDIOnumber0Audio stream.
VIDEOnumber1Video stream.
TEXTnumber2Text stream.
APPLICATIONnumber3Application stream.
MESSAGEnumber4Message stream.

carrierPlugin.StreamState : enum

Carrier stream state The stream state will be changed according to the phase of the stream.

Kind: instance enum of carrierPlugin Properties

NameTypeDefaultDescription
RAWnumber0Raw stream.
INITIALIZEDnumber1Initialized stream.
TRANSPORT_READYnumber2The underlying transport is ready for the stream to start.
CONNECTINGnumber3The stream is trying to connect the remote.
CONNECTEDnumber4The stream connected with remove peer.
DEACTIVATEDnumber5The stream is deactived.
CLOSEDnumber6The stream closed gracefully.
ERRORnumber7The stream is on error, cannot to continue.

carrierPlugin.CandidateType : enum

Carrier Stream's candidate type.

Kind: instance enum of carrierPlugin Properties

NameTypeDefaultDescription
HOSTnumber0Host candidate.
SERVE_RREFLEXIVEnumber1Server reflexive, only valid to ICE transport.
PEER_REFLEXIVEnumber2Peer reflexive, only valid to ICE transport.
RELAYEDnumber3Relayed Candidate, only valid to ICE tranport.

carrierPlugin.NetworkTopology : enum

Carrier network topology for session peers related to each other.

Kind: instance enum of carrierPlugin Properties

NameTypeDefaultDescription
LANnumber0LAN network topology.
P2Pnumber1P2P network topology.
RELAYEDnumber2Relayed netowrk topology.

carrierPlugin.PortForwardingProtocol : enum

Port forwarding supported protocols.

Kind: instance enum of carrierPlugin Properties

NameTypeDefaultDescription
TCPnumber1TCP protocol.

carrierPlugin.CloseReason : enum

Multiplexing channel close reason mode.

Kind: instance enum of carrierPlugin Properties

NameTypeDefaultDescription
NORMALnumber0Channel closed normaly.
TIMEOUTnumber1Channel closed because of timeout.
ERRORnumber2Channel closed because error occured.

carrierPlugin.StreamMode : enum

Carrier stream mode.

Kind: instance enum of carrierPlugin Properties

NameTypeDefaultDescription
COMPRESSnumber1Compress option, indicates data would be compressed before transmission. For now, just reserved this bit option for future implement.
PLAINnumber2Encrypt option, indicates data would be transmitted with plain mode. which means that transmitting data would be encrypted in default.
RELIABLEnumber4Relaible option, indicates data transmission would be reliable, and be guranteed to received by remote peer, which acts as TCP transmission protocol. Without this option bitwised, the transmission would be unreliable as UDP transmission protocol.
MULTIPLEXINGnumber8Multiplexing option, indicates multiplexing would be activated on enstablished stream, and need to use multipexing APIs related with channel instread of APIs related strema to send/receive data.
PORT_FORWARDINGnumber16PortForwarding option, indicates port forwarding would be activated on established stream. This options should bitwise with 'Multiplexing' option.

carrierPlugin.getVersion(onSuccess, onError, onSuccess)

Get current version of Carrier node.

Kind: instance method of carrierPlugin

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a String: The version of carrier node.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
onSuccesscallbackThe version of carrier node

carrierPlugin.isValidId(onSuccess, onError, id)

Check if the ID is Carrier node id.

Kind: instance method of carrierPlugin

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a Boolean: True if id is valid, otherwise false.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
idstringThe carrier node id to be check.

carrierPlugin.isValidAddress(onSuccess, onError, address)

Check if the carrier node address is valid.

Kind: instance method of carrierPlugin

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a Boolean: True if key is valid, otherwise false.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
addressstringThe carrier node address to be check.

carrierPlugin.getIdFromAddress(onSuccess, onError, address)

Get carrier ID from carrier node address.

Kind: instance method of carrierPlugin

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a String: User id if address is valid, otherwise null.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
addressstringThe carrier node address.

carrierPlugin.createObject(onSuccess, onError, options, callbacks)

Create a carrier object instance. After initializing the instance, it's ready to start and therefore connect to carrier network.

Kind: instance method of carrierPlugin

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
optionsOptionsThe options to set for creating carrier node. If set to null, will use default.
callbacksCarrierCallbacksThe callbacks for carrier node.

Stream

Kind: global class

new Stream()

The class representing Carrier stream.

stream.id

Kind: instance property of Stream Properties

NameTypeDescription
idnumberStream ID.

stream.carrier

Kind: instance property of Stream Properties

NameTypeDescription
carrierCarrierParent carrier object.

stream.session

Kind: instance property of Stream Properties

NameTypeDescription
sessionSessionParent session object.

stream.on(name, callback)

Add or remove Stream callback.

Kind: instance method of Stream

ParamTypeDescription
namestringThe callback name.
callbackfunctionThe function to add or change callback function. If set to null, will remove callback.

stream.getTransportInfo(onSuccess, onError)

Get tranport info of carrier stream.

Kind: instance method of Stream

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a TransportInfo object
onErrorfunctionThe function to call when error, the param is a String. Or set to null.

stream.write(onSuccess, onError, data)

Send outgoing data to remote peer. If the stream is in multiplexing mode, application can not call this function.

Kind: instance method of Stream

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a number: Bytes of data sent.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
database64The send data.

stream.openChannel(onSuccess, onError, cookie)

Open a new channel on multiplexing stream. If the stream is in multiplexing mode, application can not call this function.

Kind: instance method of Stream

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a number: New channel ID.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
cookiestringThe application defined data passed to remote peer

stream.closeChannel(onSuccess, onError, channel)

Close a new channel on multiplexing stream. If the stream is in multiplexing mode, application can not call this function.

Kind: instance method of Stream

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
channelnumberThe channel ID to close

stream.writeChannel(onSuccess, onError, channel, data)

Send outgoing data to remote peer. If the stream is in multiplexing mode, application can not call this function.

Kind: instance method of Stream

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a number: Bytes of data sent.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
channelnumberThe current channel ID.
database64The send data.

stream.pendChannel(onSuccess, onError, channel)

Request remote peer to pend channel data sending. If the stream is in multiplexing mode, application can not call this function.

Kind: instance method of Stream

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
channelnumberThe current channel ID.

stream.resumeChannel(onSuccess, onError, channel)

Request remote peer to resume channel data sending. If the stream is in multiplexing mode, application can not call this function.

Kind: instance method of Stream

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
channelnumberThe current channel ID.

stream.openPortForwarding(onSuccess, onError, service, protocol, host, port)

Open a port forwarding to remote service over multiplexing. If the stream is in multiplexing mode, application can not call this function.

Kind: instance method of Stream

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a number: Port forwarding ID.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
servicestringThe remote service name
protocolPortForwardingProtocolPort forwarding protocol
hoststringLocal host or ip to binding. If host is null, port forwarding will bind to localhost
portnumberLocal port to binding.

stream.closePortForwarding(onSuccess, onError, portForwarding)

Close a port forwarding. If the stream is in multiplexing mode, application can not call this function.

Kind: instance method of Stream

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
portForwardingnumberThe portforwarding ID.

Session

Kind: global class

new Session()

The class representing Carrier Session.

session.peer

Kind: instance property of Session Properties

NameTypeDescription
peerstringThe remote peer userid.

session.carrier

Kind: instance property of Session Properties

NameTypeDescription
carrierCarrierParent carrier object.

session.close()

Close a session to friend. All resources include streams, channels, portforwardings associated with current session will be destroyed.

Kind: instance method of Session

session.request(onSuccess, onError, handler)

Send session request to the friend.

Kind: instance method of Session

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
handleronSessionRequestCompleteA handler to the SessionRequestCompleteHandler to receive the session response

session.replyRequest(onSuccess, onError, status, reason)

Reply the session request from friend.

This function will send a session response to friend.

Kind: instance method of Session

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
statusnumberThe status code of the response. 0 is success, otherwise is error
reasonstringThe error message if status is error, or null if success

session.start(onSuccess, onError, 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.

Kind: instance method of Session

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
sdpstringThe remote user's SDP. Reference: https://tools.ietf.org/html/rfc4566

session.addStream(onSuccess, onError, type, options, callbacks)

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.

Kind: instance method of Session

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a Stream object: The new added carrier stream.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
typeStreamTypeThe stream type defined in StreamType
optionsnumberThe stream mode options. options are constructed by a bitwise-inclusive OR of flags
callbacksStreamCallbacksThe stream callbacks.

session.removeStream(onSuccess, onError, stream)

Remove a stream from session.

Kind: instance method of Session

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
streamstreamThe Stream to be removed

session.addService(onSuccess, onError, service, protocol, host, port)

Add a new portforwarding service to session.

The registered services can be used by remote peer in portforwarding request.

Kind: instance method of Session

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
servicestringThe new service name, should be unique in session scope.
protocolPortForwardingProtocolThe protocol of the service.
hoststringThe host name or ip of the service.
portnumberThe port of the service.

session.removeService(onSuccess, onError, service)

Remove a portforwarding server to session.

This function has not effect on existing portforwarings.

Kind: instance method of Session

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
servicestringThe service name.

Carrier

Kind: global class

new Carrier()

The class representing Carrier.

carrier.nodeId

Kind: instance property of Carrier Properties

NameTypeDescription
nodeIdstringNode id.

carrier.userId

Kind: instance property of Carrier Properties

NameTypeDescription
userIdstringUser id.

carrier.address

Kind: instance property of Carrier Properties

NameTypeDescription
addressstringNode address.

carrier.nospam

Kind: instance property of Carrier Properties

NameTypeDescription
nospamnumberThe nospam for Carrier address is used to eliminate spam friend.

carrier.presence

Kind: instance property of Carrier Properties

NameTypeDescription
presencenumberPresence status.

carrier.on(name, callback)

Add or remove Carrier callback.

Kind: instance method of Carrier

ParamTypeDescription
namestringThe callback name.
callbackfunctionThe function to add or change callback function. If set to null, will remove callback.

carrier.start(onSuccess, onError, iterateInterval)

Start carrier node asynchronously to connect to carrier network. If the connection to network is successful, carrier node starts working.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
iterateIntervalnumberInternal loop interval, in milliseconds.

carrier.getSelfInfo(onSuccess, onError)

Get self user information.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a UserInfo: the user information to the carrier node.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.

carrier.setSelfInfo(onSuccess, onError, userinfo)

Update self user information. After self user information changed, carrier node will update this information to carrier network, and thereupon network broadcasts the change to all friends.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
userinfoUserInfoThe user information to update for this carrier node.

carrier.isReady(onSuccess, onError)

Check if carrier node instance is being ready.

All carrier interactive APIs should be called only if carrier node instance is being ready.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a Boolean: true if the carrier node instance is ready, or false if not.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.

carrier.getFriends(onSuccess, onError)

Get friends list.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a {friendId: info} Object: The list of friend information to current user.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.

carrier.getFriend(onSuccess, onError, userId)

Get specified friend information.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a FriendInfo: The friend information.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
userIdstringThe user identifier of friend

carrier.labelFriend(onSuccess, onError, userId, label)

Set the label of the specified friend.

The label of a friend is a private alias name for current user. It can be seen by current user only, and has no impact to the target friend itself.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
userIdstringThe friend's user identifier
labelstringThe new label of specified friend

carrier.isFriend(onSuccess, onError, userId)

Check if the user ID is friend.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a Boolean: True if the user is a friend, or false if not.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
userIdstringThe userId to check.

carrier.addFriend(onSuccess, onError, address, hello)

Add friend by sending a new friend request.

This function will add a new friend with specific address, and then send a friend request to the target node.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
addressstringthe target user address of remote carrier node.
hellostringPIN for target user, or any application defined content.

carrier.acceptFriend(onSuccess, onError, userId)

Accept the friend request.

This function is used to add a friend in response to a friend request.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
userIdstringThe user id who want be friend with us.

carrier.removeFriend(onSuccess, onError, userId)

Remove a friend.

This function will remove a friend on this carrier node.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
userIdstringThe target user id to remove friendship

carrier.sendFriendMessage(onSuccess, onError, to, message)

Send a message to a friend.

The message length may not exceed MAX_APP_MESSAGE_LEN, and message itself should be text-formatted. Larger messages must be split by application and sent as separate messages. Other nodes can reassemble the fragments.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
tostringThe target id
messagestringThe message content defined by application

carrier.inviteFriend(onSuccess, onError, to, data, handler)

Send invite request to a friend.

Application can attach the application defined data with in the invite request, and the data will send to target friend.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
tostringThe target id
datastringThe application defined data send to target user
handleronFriendInviteResponseThe handler to receive invite reponse

carrier.replyFriendInvite(onSuccess, onError, to, status, reason, data)

Reply the friend invite request.

This function will send a invite response to friend.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
tostringThe id who send invite request
statusnumberThe status code of the response. 0 is success, otherwise is error
reasonstringThe error message if status is error, or null if success
datastringThe application defined data send to target user. If the status is error, this will be ignored

carrier.newSession(onSuccess, onError, to)

Create a new session to a friend.

The session object represent a conversation handle to a friend.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success, the param is a Session Object: The new Session object
onErrorfunctionThe function to call when error, the param is a String. Or set to null.
tostringThe target id(userid or userid@nodeid).

carrier.destroy(onSuccess, onError)

Disconnect carrier node from carrier network, and destroy all associated resources to carreier node instance. After calling the method, the carrier node instance becomes invalid.

Kind: instance method of Carrier

ParamTypeDescription
onSuccessfunctionThe function to call when success.
onErrorfunctionThe function to call when error, the param is a String. Or set to null.

BootstrapNode : Object

The Carrier user information.

Kind: global typedef Properties

NameTypeDescription
ipv4stringThe server ipv4.
ipv6stringThe server ipv6.
portstringThe server port.
publicKeystringThe publicKey.

Options : Object

Options defines several settings that control the way the Carrier node connects to the carrier network. Default values are not defined for bootstraps options, so application should be set bootstrap nodes clearly.

Kind: global typedef Properties

NameTypeDescription
udpEnabledBooleanSet to use udp transport or not. Setting this value to false will force carrier node to TCP only, which will potentially slow down the message to run through.
persistentLocationstringSet the persistent data location. The location must be set.
bootstrapsArrayBootstrapNode Array.

UserInfo : Object

The Carrier user information.

Kind: global typedef Properties

NameTypeDescription
userIdstringThe user ID.
namestringThe nickname.
descriptionstringuser's brief description.
hasAvatarBooleanHas avatar or not.
genderstringThe gender.
phonestringThe phone number.
emailstringThe email address.
regionstringThe region.

FriendInfo : Object

The Carrier friend information.

Kind: global typedef Properties

NameTypeDescription
userInfoUserInfoThe user info.
presencePresenceStatusThe presence status.
connectionConnectionStatusThe connection status.
labelstringThe friend's label name.

AddressInfo : Object

The netword address information.

Kind: global typedef Properties

NameTypeDescription
typeCandidateTypeThe address type.
addressstringThe address.
portstringThe port.
relatedAddressstringThe related address status.
relatedPortstringThe related port.

TransportInfo : Object

The netword transport information.

Kind: global typedef Properties

NameTypeDescription
topologyNetworkTopologyThe network topology.
localAddrAddressInfoThe local address.
remoteAddrAddressInfoThe remote address.

CarrierCallbacks : Object

The Carrier callbacks.

Kind: global typedef Properties

NameTypeDescription
onConnectiononConnectionThe callback function to process the self connection status.
onReadyonReadyThe callback function to process the ready notification.
onSelfInfoChangedonSelfInfoChangedThe callback function to process the self info changed event.
onFriendsonFriendsThe callback function to iterate the each friend item in friend list.
onFriendConnectiononFriendConnectionThe callback function to process the friend connections status changed event.
onFriendInfoChangedonFriendInfoChangedThe callback function to process the friend information changed event.
onFriendPresenceonFriendPresenceThe callback function to process the friend presence changed event.
onFriendRequestonFriendRequestThe callback function to process the friend request.
onFriendAddedonFriendAddedThe callback function to process the new friend added event.
onFriendRemovedonFriendRemovedThe callback function to process the friend removed event.
onFriendMessageonFriendMessageThe callback function to process the friend message.
onFriendInviteRequestonFriendInviteRequestThe callback function to process the friend invite request.
onSessionRequestonSessionRequestThe callback function that handle session request.

StreamCallbacks : Object

The Stream callbacks.

Kind: global typedef Properties

NameTypeDescription
onStateChangedonStateChangedThe callback function to report state of stream when it's state changes.
onStreamDataonStreamDataThe callback will be called when the stream receives incoming packet.
onChannelOpenonChannelOpenThe callback function to be called when new multiplexing channel opened.
onChannelOpenedonChannelOpenedThe callback function to be called when new multiplexing channel opened.
onChannelCloseonChannelCloseThe callback function to be called when channel close.
onChannelDataonChannelDataThe callback functiont to be called when channel received incoming data.
onChannelPendingonChannelPendingThe callback function to be called when remote peer ask to pend data sending.
onChannelResumeonChannelResumeThe callback function to be called when remote peer ask to resume data sending.

onFriendInviteResponse : function

The callback function to process the friend invite response.

Kind: global typedef

ParamTypeDescription
fromstringThe target user id who send friend invite response
statusnumberThe status code of invite response. 0 is success, otherwise error
reasonstringThe error message if status is error, otherwise null
datastringThe application defined data return by target user

onSessionRequestComplete : function

The callback function to receive session request complete event.

Kind: global typedef

ParamTypeDescription
sessionSessionThe carrier session instance.
statusnumberThe status code of the response. 0 is success, otherwise is error.
reasonstringThe error message if status is error, or nil if session request error happened.
sdpstringThe remote users SDP. Reference: https://tools.ietf.org/html/rfc4566

onStateChanged : function

The callback function to report state of stream when it's state changes.

Kind: global typedef

ParamTypeDescription
streamStreamThe carrier stream instance
stateStreamStateStream state defined in StreamState

onStreamData : function

The callback will be called when the stream receives incoming packet. If the stream enabled multiplexing mode, application will not receive stream-layered data callback any more. All data will reported as multiplexing channel data.

Kind: global typedef

ParamTypeDescription
streamStreamThe carrier stream instance
database64The received packet data.

onChannelOpen : function

The callback function to be called when new multiplexing channel request to open.

Kind: global typedef

ParamTypeDescription
streamStreamThe carrier stream instance
channelnumberThe current channel ID.
cookiestringApplication defined string data send from remote peer.

onChannelOpened : function

The callback function to be called when new multiplexing channel opened.

Kind: global typedef

ParamTypeDescription
streamStreamThe carrier stream instance
channelnumberThe current channel ID.

onChannelClose : function

The callback function to be called when channel close.

Kind: global typedef

ParamTypeDescription
streamStreamThe carrier stream instance
channelnumberThe current channel ID.
reasonstringChannel close reason code, defined in CloseReason.

onChannelData : function

The callback functiont to be called when channel received incoming data.

Kind: global typedef

ParamTypeDescription
streamStreamThe carrier stream instance
channelnumberThe current channel ID.
database64The received packet data.

onChannelPending : function

The callback function to be called when remote peer ask to pend data sending.

Kind: global typedef

ParamTypeDescription
streamStreamThe carrier stream instance
channelnumberThe current channel ID.

onChannelResume : function

The callback function to be called when remote peer ask to resume data sending.

Kind: global typedef

ParamTypeDescription
streamStreamThe carrier stream instance
channelnumberThe current channel ID.

onConnection : function

The callback function to process the self connection status.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
statusnumberCurrent connection status. @see ConnectionStatus

onReady : function

The callback function to process the ready notification.

Application should wait this callback invoked before calling any function to interact with friends.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance

onSelfInfoChanged : function

The callback function to process the self info changed event.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
userInfoUserInfoThe updated user information

onFriends : function

The callback function to iterate the each friend item in friend list.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
friendsArrayThe friends list.

onFriendConnection : function

The callback function to process the friend connections status changed event.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
friendIdstringThe friend's user id.
statusnumberThe connection status of friend. @see ConnectionStatus

onFriendInfoChanged : function

The callback function to process the friend information changed event.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
friendIdstringThe friend's user id
infoFriendInfoThe update friend information

onFriendPresence : function

The callback function to process the friend presence changed event.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
friendIdstringThe friend's user id
presencenumberThe presence status of the friend

onFriendRequest : function

The callback function to process the friend request.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
userIdstringThe user id who want be friend with current user
infoUserInfoThe user information to userId
hellostringThe PIN for target user, or any application defined content

onFriendAdded : function

The callback function to process the new friend added event.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
friendInfoFriendInfoThe added friend's information

onFriendRemoved : function

The callback function to process the friend removed event.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
friendIdstringThe friend's user id

onFriendMessage : function

The callback function to process the friend message.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
fromstringThe id from who send the message
messagestringThe message content

onFriendInviteRequest : function

The callback function to process the friend invite request.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
fromstringThe user id from who send the invite request
datastringThe application defined data sent from friend

onSessionRequest : function

The callback function that handle session request.

Kind: global typedef

ParamTypeDescription
carrierCarrierCarrier node instance
fromstringThe id who send the message
sdpstringThe remote users SDP. Reference: https://tools.ietf.org/html/rfc4566