Interface nsIWebSocketChannelType

Low-level websocket API: handles network protocol.

This is primarly intended for use by the higher-level nsIWebSocket.idl. We are also making it scriptable for now, but this may change once we have WebSockets for Workers.

Hierarchy

Properties

URI: nsIURI

The readonly URI corresponding to the protocol connection after any redirections are completed.

extensions: string

Sec-Websocket-Extensions response header value

httpChannelId: uint64_t

The channelId of the underlying http channel. It's available only after nsIWebSocketListener::onStart

loadGroup: nsILoadGroup

The load group of of the websocket

loadInfo: nsILoadInfo

The load info of the websocket

notificationCallbacks: nsIInterfaceRequestor

The notification callbacks for authorization, etc..

originalURI: nsIURI

The original URI used to construct the protocol connection. This is used in the case of a redirect or URI "resolution" (e.g. resolving a resource: URI to a file: URI) so that the original pre-redirect URI can still be obtained. This is never null.

pingInterval: number

This value determines how often (in seconds) websocket keepalive pings are sent. If set to 0 (the default), no pings are ever sent.

This value can currently only be set before asyncOpen is called, else NS_ERROR_IN_PROGRESS is thrown.

Be careful using this setting: ping traffic can consume lots of power and bandwidth over time.

pingTimeout: number

This value determines how long (in seconds) the websocket waits for the server to reply to a ping that has been sent before considering the connection broken.

This value can currently only be set before asyncOpen is called, else NS_ERROR_IN_PROGRESS is thrown.

protocol: string

Sec-Websocket-Protocol value

securityInfo: nsITransportSecurityInfo

Transport-level security information (if any)

serial: number

Unique ID for this channel. It's not readonly because when the channel is created via IPC, the serial number is received from the child process.

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • Asynchronously open the websocket connection. Received messages are fed to the socket listener as they arrive. The socket listener's methods are called on the thread that calls asyncOpen and are not called until after asyncOpen returns. If asyncOpen returns successfully, the protocol implementation promises to call at least onStop on the listener.

    NOTE: Implementations should throw NS_ERROR_ALREADY_OPENED if the websocket connection is reopened.

    Parameters

    • aURI: nsIURI

      the uri of the websocket protocol - may be redirected

    • aOrigin: string

      the uri of the originating resource

    • aOriginAttributes: any

      attributes of the originating resource.

    • aInnerWindowID: number

      the inner window ID

    • aListener: nsIWebSocketListener

      the nsIWebSocketListener implementation

    • aContext: nsISupports

      an opaque parameter forwarded to aListener's methods

    Returns void

  • Parameters

    • aURI: nsIURI
    • aOrigin: string
    • aOriginAttributes: OriginAttributes
    • aInnerWindowID: number
    • aListener: nsIWebSocketListener
    • aContext: nsISupports

    Returns void

  • Close the websocket connection for writing - no more calls to sendMsg or sendBinaryMsg should be made after calling this. The listener object may receive more messages if a server close has not yet been received.

    Parameters

    • aCode: number

      the websocket closing handshake close code. Set to 0 if you are not providing a code.

    • aReason: string

      the websocket closing handshake close reason

    Returns void

  • Similar to the previous one but without nsICookieJarSettings. This method is used by JS code where nsICookieJarSettings is not exposed.

    Parameters

    • aLoadingNode: Node
    • aLoadingPrincipal: nsIPrincipal
    • aTriggeringPrincipal: nsIPrincipal
    • aSecurityFlags: number
    • aContentPolicyType: nsContentPolicyType

    Returns void

  • Init the WebSocketChannel with LoadInfo arguments.

    Returns

    reference to the new nsIChannel object

    Keep in mind that URIs coming from a webpage should never use the systemPrincipal as the loadingPrincipal.

    Please note, if you provide both a loadingNode and a loadingPrincipal, then loadingPrincipal must be equal to loadingNode->NodePrincipal(). But less error prone is to just supply a loadingNode.

    Parameters

    • aLoadingNode: Node
    • aLoadingPrincipal: nsIPrincipal
    • aTriggeringPrincipal: nsIPrincipal
    • aCookieJarSettings: nsICookieJarSettings
    • aSecurityFlags: number
    • aContentPolicyType: nsContentPolicyType

      These will be used as values for the nsILoadInfo object on the created channel. For details, see nsILoadInfo in nsILoadInfo.idl

    • aSandboxFlags: number

    Returns number

  • Use to send binary message down the connection to WebSocket peer.

    Parameters

    • aMsg: string

      the data to send

    Returns void

  • Use to send a binary stream (Blob) to Websocket peer.

    Parameters

    • aStream: nsIInputStream

      The input stream to be sent.

    • length: number

    Returns void

  • Use to send text message down the connection to WebSocket peer.

    Parameters

    • aMsg: string

      the utf8 string to send

    Returns void

  • Set a nsITransportProvider and negotated extensions to be used by this channel. Calling this function also means that this channel will implement the server-side part of a websocket connection rather than the client-side part.

    Parameters

    • aProvider: nsITransportProvider
    • aNegotiatedExtensions: string

    Returns void

Generated using TypeDoc