export function startServer ( processMessage , port = 9838 ) { var net = require ( 'net' ) ; var JsonSocket = require ( 'json-socket' ) ; var server = net . createServer ( ) ; server . listen ( port ) ; server . on ( 'connection' , function ( socket ) { socket = new JsonSocket ( socket ) ; socket . on ( 'message' , function ( message ) { processMessage ( message ) ; } ) ; } ) ; const WebSocket = require ( 'ws' ) ; const wss = new WebSocket . Server ( { port : 9839 } ) ; wss . on ( 'connection' , function connection ( ws ) { console . log ( 'connected' ) ; ws . on ( 'message' , function incoming ( message ) { if ( message ) { var parsed = JSON . parse ( message ) ; processMessage ( parsed ) ; } } ) ; } ) ; }