Options
All
  • Public
  • Public/Protected
  • All
Menu

Module CarrierPlugin

This is about carrier, a decentralized distributed peer-to-peer networking system. With carrier, you can friend someone and use sessions, file transfers among friends.

Please use 'CarrierPlugin' as the plugin name in the manifest.json if you want to use this facility.

Usage:
declare let carrierManager: CarrierPlugin.CarrierManager;

Index

Type aliases

AddressInfo

AddressInfo: object

The network address information.

Type declaration

  • address: string

    The address.

  • port: string

    The port.

  • Optional relatedAddress?: string

    The related address status.

  • Optional relatedPort?: string

    The related port.

  • type: CandidateType

    The address type.

BootstrapNode

BootstrapNode: object

The bootstrap node information.

Type declaration

  • ipv4: string

    The server ipv4.

  • ipv6: string

    The server ipv6.

  • port: string

    The server port.

  • publicKey: string

    The public key

CarrierCallbacks

CarrierCallbacks: object & GroupCallbacks

The Carrier callbacks.

FileTransferCallbacks

FileTransferCallbacks: object

Type declaration

  • onCancel: function
    • onCancel(fileTransfer: FileTransfer, fileId: string, status: Int, reason: string): any
    • An application-defined function that handles cancel file transfer notification from the peer.

      callback

      onCancel

      Parameters

      • fileTransfer: FileTransfer

        The fileTransfer instance .

      • fileId: string

        The unique identifier of transferring file.

      • status: Int

        Cancel transfer status code.

      • reason: string

        Cancel transfer reason.

      Returns any

  • onData: function
    • onData(fileTransfer: FileTransfer, fileId: string, data: string): any
    • An application-defined function that performs receiving data.

      callback

      onData

      Parameters

      • fileTransfer: FileTransfer

        The fileTransfer instance .

      • fileId: string

        The unique identifier of transferring file.

      • data: string

        The received data.

      Returns any

  • onDataFinished: function
    • onDataFinished(fileTransfer: FileTransfer, fileId: string): any
    • An application-defined function that handles the event of end of receiving data.

      callback

      onDataFinished

      Parameters

      • fileTransfer: FileTransfer

        The fileTransfer instance .

      • fileId: string

        The unique identifier of transferring file.

      Returns any

  • onFileRequest: function
    • onFileRequest(fileTransfer: FileTransfer, fileId: string, filename: string, size: Int): any
    • An application-defined function that handles transfer file request event.

      callback

      onFileRequest

      Parameters

      • fileTransfer: FileTransfer

        The fileTransfer instance .

      • fileId: string

        The file identifier.

      • filename: string

        The file name.

      • size: Int

        The total file size.

      Returns any

  • onPending: function
    • onPending(fileTransfer: FileTransfer, fileId: string): any
    • An application-defined function that handles pause file transfer notification from the peer.

      callback

      onPending

      Parameters

      • fileTransfer: FileTransfer

        The fileTransfer instance .

      • fileId: string

        The unique identifier of transferring file.

      Returns any

  • onPullRequest: function
    • onPullRequest(fileTransfer: FileTransfer, fileId: string, offset: string): any
    • An application-defined function that handles file transfer pull request event.

      callback

      onPullRequest

      Parameters

      • fileTransfer: FileTransfer

        The fileTransfer instance.

      • fileId: string

        The unique identifier of transferring file.

      • offset: string

        The offset of file where transfer begins.

      Returns any

  • onResume: function
    • An application-defined function that handles resume file transfer notification from the peer.

      callback

      onResume

      Parameters

      • fileTransfer: FileTransfer

        The fileTransfer instance .

      • fileId: string

        The unique identifier of transferring file.

      Returns any

  • onStateChanged: function
    • The callback function that handles the state changed event. An application-defined function that handles the state changed event.

      callback

      onStateChanged

      Parameters

      Returns any

FileTransferInfo

FileTransferInfo: object

The file transfer information.

Type declaration

  • fileId: string

    The file ID.

  • filename: string

    The file name.

  • size: Number

    The file size.

FriendInfo

FriendInfo: object

The Carrier friend information such as user info, presence status, connection status and label name.

Type declaration

GroupCallbacks

GroupCallbacks: object

Type declaration

  • onGroupConnected: function
    • onGroupConnected(group: Group): any
    • The callback function that handles group connect status.

      callback

      onGroupConnected

      Parameters

      • group: Group

        The group instance .

      Returns any

  • onGroupMessage: function
    • onGroupMessage(group: Group, from: string, message: string): any
    • The callback function that handles group message.

      callback

      onGroupMessage

      Parameters

      • group: Group

        The group instance .

      • from: string

        The friend's user ID.

      • message: string

        The message content

      Returns any

  • onGroupTitle: function
    • onGroupTitle(group: Group, from: string, title: string): any
    • The callback function that handles group title changed.

      callback

      onGroupTitle

      Parameters

      • group: Group

        The group instance .

      • from: string

        The user ID of the modifier

      • title: string

        New group title

      Returns any

  • onPeerListChanged: function
    • onPeerListChanged(group: Group): any
    • The callback function that handles peer list changed.

      callback

      onPeerListChanged

      Parameters

      • group: Group

        The group instance .

      Returns any

  • onPeerName: function
    • onPeerName(group: Group, peerId: string, peerName: string): any
    • The callback function that handles peer name changed.

      callback

      onPeerName

      Parameters

      • group: Group

        The group instance .

      • peerId: string

        The peer's user ID.

      • peerName: string

        The peer's name.

      Returns any

Int

Int: Opaque<number, "Int">

OnFriendInviteResponse

OnFriendInviteResponse: function

The callback function to process the friend invite response.

callback

OnFriendInviteResponse

param

The target user ID of who sends a friend invite response

param

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

param

The error message if status is error, otherwise null

param

The application defined data return by target user

Type declaration

    • (from: string, status: Number, reason: string, data: string): void
    • Parameters

      • from: string
      • status: Number
      • reason: string
      • data: string

      Returns void

OnFriendMessageReceipt

OnFriendMessageReceipt: function

The callback function to process to friend message receipt notification

callback

OnFriendMessageReceipt

param

The message identifer

param

The message receipt state

Type declaration

    • (messageId: number, state: Number): void
    • Parameters

      • messageId: number
      • state: Number

      Returns void

OnSessionRequestComplete

OnSessionRequestComplete: function

The callback function to receive session request complete event.

callback

OnSessionRequestComplete

param

The carrier session instance.

param

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

param

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

param

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

Type declaration

    • (session: Session, status: Number, reason: string, sdp: string): void
    • Parameters

      • session: Session
      • status: Number
      • reason: string
      • sdp: string

      Returns void

Opaque

Opaque<T, K>: T & object

Type parameters

  • T

  • K

Options

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.

Type declaration

  • binaryUsed: Boolean

    Send/receive binary message

  • persistentLocation: string

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

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

StreamCallbacks

StreamCallbacks: object

The Stream callbacks.

Type declaration

  • onChannelClose: function
    • onChannelClose(stream: Stream, channel: Number, reason: string): any
    • The callback function to be called when channel close.

      callback

      onChannelClose

      Parameters

      • stream: Stream

        The carrier stream instance

      • channel: Number

        The current channel ID.

      • reason: string

        Channel close reason code, defined in CloseReason.

      Returns any

  • onChannelData: function
    • onChannelData(stream: Stream, channel: Number, data: string): any
    • The callback function to be called when channel receives incoming data.

      callback

      onChannelData

      Parameters

      • stream: Stream

        The carrier stream instance

      • channel: Number

        The current channel ID.

      • data: string

        The received packet data.

      Returns any

  • onChannelOpen: function
    • onChannelOpen(stream: Stream, channel: Number, cookie: string): any
    • The callback function to be called when new multiplexing channel request to open.

      callback

      onChannelOpen

      Parameters

      • stream: Stream

        The carrier stream instance

      • channel: Number

        The current channel ID.

      • cookie: string

        Application defined string data receives from remote peer.

      Returns any

  • onChannelOpened: function
    • onChannelOpened(stream: Stream, channel: Number): any
    • The callback function to be called when new multiplexing channel opened.

      callback

      onChannelOpened

      Parameters

      • stream: Stream

        The carrier stream instance

      • channel: Number

        The current channel ID.

      Returns any

  • onChannelPending: function
    • onChannelPending(stream: Stream, channel: Number): any
    • The callback function to be called when remote peer asks to pend data sending.

      callback

      onChannelPending

      Parameters

      • stream: Stream

        The carrier stream instance

      • channel: Number

        The current channel ID.

      Returns any

  • onChannelResume: function
    • onChannelResume(stream: Stream, channel: Number): any
    • The callback function to be called when remote peer ask to resume data sending.

      callback

      onChannelResume

      Parameters

      • stream: Stream

        The carrier stream instance

      • channel: Number

        The current channel ID.

      Returns any

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

      callback

      onStateChanged

      Parameters

      • stream: Stream

        The carrier stream instance

      • state: StreamState

        Stream state defined in StreamState

      Returns any

  • onStreamData: function
    • onStreamData(stream: Stream, data: string): any
    • 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.

      callback

      onStreamData

      Parameters

      • stream: Stream

        The carrier stream instance

      • data: string

        The received packet data.

      Returns any

TransportInfo

TransportInfo: object

The network transport information.

Type declaration

UserInfo

UserInfo: object

The Carrier user information such as ID, nickname, brief description, avatar, gender, phone number, email address and region.

Type declaration

  • description: string

    User's brief description.

  • email: string

    The email address.

  • gender: string

    The gender.

  • hasAvatar: Boolean

    Has avatar or not.

  • name: string

    The nickname.

  • phone: string

    The phone number.

  • region: string

    The region.

  • userId: string

    The user ID.