0.2.6 • Published 3 years ago

react-native-tv-ws-protocol v0.2.6

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

react-native-tv-ws-protocol

This package is a wrapped websocket protocol, also supports self-certificate bypass

Installation

npm install react-native-tv-ws-protocol --save

Features

  • Conforms to all of the base Autobahn test suite.
  • Nonblocking. Everything happens in the background, thanks to GCD.
  • TLS/WSS support.
  • Compression Extensions support (RFC 7692)

Usage

import module

import TvWsProtocol from "react-native-tv-ws-protocol";

Connect to the WebSocket Server

Once imported, you can open a connection to your WebSocket server.

    TvWsProtocol.create('http://localhost:8080');

After you are connected, there is either a pack of events that you can use for process WebSocket events.

Receiving data from a WebSocket

    TvWsProtocol.onmessage = (message) => {
      //...
    };

Writing to a WebSocket

write a string frame

    TvWsProtocol.send(
      JSON.stringify({
        method: 'test',
        params: {
          data: { action_type: 'DEEP_LINK', appId: '111299001912' },
          event: 'ed.apps.launch',
          to: 'host',
        },
      })
    );

disconnect

The disconnect method does what you would expect and closes the socket.

    TvWsProtocol.close()

SSL Pinning

SSL Pinning is also supported in this module.

Allow Self-signed certificates:

    TvWsProtocol.create('http://localhost:8080', {
      rejectUnauthorized: false,
    });

Some event you might need

    TvWsProtocol.onconnect = () => {
      //...
    };
    TvWsProtocol.ondisconnect = () => {
      //...
    };
    TvWsProtocol.onerror = (error) => {
      //...
    };

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.1

3 years ago

0.2.2

3 years ago

0.2.0

3 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.9

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago