Hierarchy

Methods

  • Creates an event emitter instance to listen for the actions

    Returns

    Call the function to remove the event

    Parameters

    • eventName: "close" | "message" | "failure" | "open"
    • callback: EventListenerCallback

      Gets as any arguments as it needs

    Returns (() => void)

      • (): void
      • Creates an event emitter instance to listen for the actions

        Returns

        Call the function to remove the event

        Returns void

  • Creates an event emitter instance to listen for the actions

    Returns

    Call the function to remove the event

    Parameters

    • eventName: "close" | "message" | "failure" | "open"
    • callback: EventListenerCallback

      Gets as any arguments as it needs

    Returns (() => void)

      • (): void
      • Creates an event emitter instance to listen for the actions

        Returns

        Call the function to remove the event

        Returns void

  • Removes the specified event and invokes the callback after it is removed

    Parameters

    Returns void

  • Triggers the event manually.

    Parameters

    • event: "close" | "message" | "failure" | "open"
    • Rest ...args: any[]

      Arguments that needs to be passed down

    Returns void

  • Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

    Parameters

    Returns void

  • Adds a one-time listener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

    Parameters

    Returns void

  • Close the web socket.

    Since

    1.1.17

    Parameters

    • params: { code: number; reason?: string }
      • code: number
      • Optional reason?: string

    Returns void

  • Send data to a web socket server.

    Returns

    Since

    1.1.17

    Parameters

    • params: { data: string | BlobImpl }
      • data: string | BlobImpl

    Returns boolean

Properties

nativeObject: { [key: string]: any }

Type declaration

  • [key: string]: any
headers: Record<string, string>

Gets headers of socket connection. If you want to change the headers, you have to call the constructor again (create a new instance).

Property

Android

Ios

Since

1.1.17

url: string

Gets url of socket connection. If you want to change the URL, you have to call the constructor again (create a new instance).

Property

Android

Ios

Since

1.1.17

Events

onOpen: (() => void)

Type declaration

    • (): void
    • Invoked when a web socket has been accepted by the web socket server.

      Deprecated

      Since

      1.1.17

      Example

      import WebSocket from '@smartface/native/net/websocket';

      const webSocket = new WebSocket();
      webSocket.on(WebSocket.Events.Open, () => {
      console.info('onOpen');
      });

      Returns void

onMessage: ((e: { string?: string; blob?: BlobImpl }) => void)

Type declaration

    • (e: { string?: string; blob?: BlobImpl }): void
    • Invoked when a message has been received.

      Deprecated

      Since

      1.1.17

      Example

      import WebSocket from '@smartface/native/net/websocket';

      const webSocket = new WebSocket();
      webSocket.on('message', (params) => {
      console.info('onMessage', params);
      });

      Parameters

      • e: { string?: string; blob?: BlobImpl }
        • Optional string?: string
        • Optional blob?: BlobImpl

      Returns void

onClose: ((e: { code: number; reason: string }) => void)

Type declaration

    • (e: { code: number; reason: string }): void
    • Invoked when the web socket has been closed.

      Deprecated

      Since

      1.1.17

      Example

      import WebSocket from '@smartface/native/net/websocket';

      const webSocket = new WebSocket();
      webSocket.on('close', (params) => {
      console.info('onClose', params);
      });

      Parameters

      • e: { code: number; reason: string }
        • code: number
        • reason: string

      Returns void

onFailure: ((e: { code: number; message: string }) => void)

Type declaration

    • (e: { code: number; message: string }): void
    • Invoked when an error occured on reading or writing to the network.

      Deprecated

      Since

      1.1.17

      Example

      import WebSocket from '@smartface/native/net/websocket';

      const webSocket = new WebSocket();
      webSocket.on('failure', (params) => {
      console.info('onFailure', params);
      });

      Parameters

      • e: { code: number; message: string }
        • code: number
        • message: string

      Returns void

Generated using TypeDoc