This package is a wrapped websocket protocol, also supports self-certificate bypass
npm install react-native-tv-ws-protocol --save
- 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)
import TvWsProtocol from "react-native-tv-ws-protocol";
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.
TvWsProtocol.onmessage = (message) => {
//...
};
TvWsProtocol.send(
JSON.stringify({
method: 'test',
params: {
data: { action_type: 'DEEP_LINK', appId: '111299001912' },
event: 'ed.apps.launch',
to: 'host',
},
})
);
The disconnect method does what you would expect and closes the socket.
TvWsProtocol.close()
SSL Pinning is also supported in this module.
Allow Self-signed certificates:
TvWsProtocol.create('http://localhost:8080', {
rejectUnauthorized: false,
});
TvWsProtocol.onconnect = () => {
//...
};
TvWsProtocol.ondisconnect = () => {
//...
};
TvWsProtocol.onerror = (error) => {
//...
};
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT