react-native-firebase/tests-new/bridge/env/node/ws.js

16 lines
388 B
JavaScript

const vm = require('./vm');
const WebSocket = require('ws');
const ws = new WebSocket(
'ws://localhost:8081/debugger-proxy?role=debugger&name=Chrome'
);
vm.send = obj => ws.send(JSON.stringify(obj));
ws.onmessage = message => vm.message(JSON.parse(message.data));
ws.onclose = event =>
!event.wasClean ? console.error('Bridge WS Error', event.message) : '';
module.exports = ws;