Module: CarrierPlugin

Classes

Carrier
Session
Stream

Type Definitions


AddressInfo

The netword address information.

Type:
  • Object
Properties:
Name Type Argument Description
type CandidateType

The address type.

address string

The address.

port string

The port.

relatedAddress string <optional>

The related address status.

relatedPort string <optional>

The related port.

Source:

BootstrapNode

The Carrier user information.

Type:
  • Object
Properties:
Name Type Description
ipv4 string

The server ipv4.

ipv6 string

The server ipv6.

port string

The server port.

publicKey string

The publicKey.

Source:

CarrierCallbacks

The Carrier callbacks.

Type:
  • Object
Properties:
Name Type Description
onConnection onConnection

The callback function to process the self connection status.

onReady onReady

The callback function to process the ready notification.

onSelfInfoChanged onSelfInfoChanged

The callback function to process the self info changed event.

onFriends onFriends

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

onFriendConnection onFriendConnection

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

onFriendInfoChanged onFriendInfoChanged

The callback function to process the friend information changed event.

onFriendPresence onFriendPresence

The callback function to process the friend presence changed event.

onFriendRequest onFriendRequest

The callback function to process the friend request.

onFriendAdded onFriendAdded

The callback function to process the new friend added event.

onFriendRemoved onFriendRemoved

The callback function to process the friend removed event.

onFriendMessage onFriendMessage

The callback function to process the friend message.

onFriendInviteRequest onFriendInviteRequest

The callback function to process the friend invite request.

onSessionRequest onSessionRequest

The callback function that handle session request.

Source:

FriendInfo

The Carrier friend information.

Type:
  • Object
Properties:
Name Type Description
userInfo UserInfo

The user info.

presence PresenceStatus

The presence status.

connection ConnectionStatus

The connection status.

label string

The friend's label name.

Source:

onChannelClose(stream, channel, reason)

The callback function to be called when channel close.

Parameters:
Name Type Description
stream Stream

The carrier stream instance

channel number

The current channel ID.

reason string

Channel close reason code, defined in CloseReason.

Source:

onChannelData(stream, channel, data)

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

Parameters:
Name Type Description
stream Stream

The carrier stream instance

channel number

The current channel ID.

data base64

The received packet data.

Source:

onChannelOpen(stream, channel, cookie)

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

Parameters:
Name Type Description
stream Stream

The carrier stream instance

channel number

The current channel ID.

cookie string

Application defined string data send from remote peer.

Source:

onChannelOpened(stream, channel)

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

Parameters:
Name Type Description
stream Stream

The carrier stream instance

channel number

The current channel ID.

Source:

onChannelPending(stream, channel)

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

Parameters:
Name Type Description
stream Stream

The carrier stream instance

channel number

The current channel ID.

Source:

onChannelResume(stream, channel)

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

Parameters:
Name Type Description
stream Stream

The carrier stream instance

channel number

The current channel ID.

Source:

onConnection(carrier, status)

The callback function to process the self connection status.

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

status number

Current connection status. @see ConnectionStatus

Source:

onFriendAdded(carrier, friendInfo)

The callback function to process the new friend added event.

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

friendInfo FriendInfo

The added friend's information

Source:

onFriendConnection(carrier, friendId, status)

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

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

friendId string

The friend's user id.

status number

The connection status of friend. @see ConnectionStatus

Source:

onFriendInfoChanged(carrier, friendId, info)

The callback function to process the friend information changed event.

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

friendId string

The friend's user id

info FriendInfo

The update friend information

Source:

onFriendInviteRequest(carrier, from, data)

The callback function to process the friend invite request.

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

from string

The user id from who send the invite request

data string

The application defined data sent from friend

Source:

onFriendInviteResponse(from, status, reason, data)

The callback function to process the friend invite response.

Parameters:
Name Type Description
from string

The target user id who send friend invite response

status number

The status code of invite response. 0 is success, otherwise error

reason string

The error message if status is error, otherwise null

data string

The application defined data return by target user

Source:

onFriendMessage(carrier, from, message)

The callback function to process the friend message.

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

from string

The id from who send the message

message string

The message content

Source:

onFriendPresence(carrier, friendId, presence)

The callback function to process the friend presence changed event.

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

friendId string

The friend's user id

presence number

The presence status of the friend

Source:

onFriendRemoved(carrier, friendId)

The callback function to process the friend removed event.

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

friendId string

The friend's user id

Source:

onFriendRequest(carrier, userId, info, hello)

The callback function to process the friend request.

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

userId string

The user id who want be friend with current user

info UserInfo

The user information to userId

hello string

The PIN for target user, or any application defined content

Source:

onFriends(carrier, friends)

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

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

friends Array

The friends list.

Source:

onReady(carrier)

The callback function to process the ready notification.

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

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

Source:

onSelfInfoChanged(carrier, userInfo)

The callback function to process the self info changed event.

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

userInfo UserInfo

The updated user information

Source:

onSessionRequest(carrier, from, sdp)

The callback function that handle session request.

Parameters:
Name Type Description
carrier Carrier

Carrier node instance

from string

The id who send the message

sdp string

The remote users SDP. Reference: https://tools.ietf.org/html/rfc4566

Source:

onSessionRequestComplete(session, status, reason, sdp)

The callback function to receive session request complete event.

Parameters:
Name Type Description
session Session

The carrier session instance.

status number

The status code of the response. 0 is success, otherwise is error.

reason string

The error message if status is error, or nil if session request error happened.

sdp string

The remote users SDP. Reference: https://tools.ietf.org/html/rfc4566

Source:

onStateChanged(stream, state)

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

Parameters:
Name Type Description
stream Stream

The carrier stream instance

state StreamState

Stream state defined in StreamState

Source:

onStreamData(stream, data)

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.

Parameters:
Name Type Description
stream Stream

The carrier stream instance

data base64

The received packet data.

Source:

Options

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.

Type:
  • Object
Properties:
Name Type Description
udpEnabled Boolean

Set 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.

persistentLocation string

Set the persistent data location. The location must be set.

bootstraps Array

BootstrapNode Array.

Source:

StreamCallbacks

The Stream callbacks.

Type:
  • Object
Properties:
Name Type Description
onStateChanged onStateChanged

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

onStreamData onStreamData

The callback will be called when the stream receives incoming packet.

onChannelOpen onChannelOpen

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

onChannelOpened onChannelOpened

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

onChannelClose onChannelClose

The callback function to be called when channel close.

onChannelData onChannelData

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

onChannelPending onChannelPending

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

onChannelResume onChannelResume

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

Source:

TransportInfo

The netword transport information.

Type:
  • Object
Properties:
Name Type Description
topology NetworkTopology

The network topology.

localAddr AddressInfo

The local address.

remoteAddr AddressInfo

The remote address.

Source:

UserInfo

The Carrier user information.

Type:
  • Object
Properties:
Name Type Description
userId string

The user ID.

name string

The nickname.

description string

user's brief description.

hasAvatar Boolean

Has avatar or not.

gender string

The gender.

phone string

The phone number.

email string

The email address.

region string

The region.

Source: