UNPKG

rnsst

Version:

React Native Storybook Screeshot Tests with Detox

25 lines (24 loc) 760 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const ws = require("ws"); class Server { constructor(port) { this.getUrl = () => { const address = this.wsServer.address(); return typeof address === 'string' ? address : `ws://localhost:${address.port}`; }; this.handleWS = (socket) => { socket.on('message', (data) => { this.wsServer.clients.forEach((c) => { c.send(data); }); }); }; this.stop = () => { this.wsServer.close(); }; this.wsServer = new ws.Server({ port }); this.wsServer.on('connection', this.handleWS); } } exports.default = Server;