slate/common/websockets.js
2020-10-25 15:56:57 -07:00

22 lines
385 B
JavaScript

import { w3cwebsocket as W3CWebSocket } from "websocket";
let client = null;
export const init = ({ resource = "" }) => {
client = new W3CWebSocket(resource);
client.onopen = () => {
console.log("WebSocket Client Connected");
};
client.onmessage = (message) => {
console.log(message);
};
return client;
};
export const getClient = () => {
return client;
};