mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-26 10:34:09 +03:00
22 lines
385 B
JavaScript
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;
|
|
};
|