Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/socket/tunnelbroker.js
// @flow | // @flow | ||||
import WebSocket from 'ws'; | import WebSocket from 'ws'; | ||||
import { type ConnectionInitializationMessage } from 'lib/types/tunnelbroker-messages.js'; | |||||
function createTunnelbrokerWebsocket() { | function createTunnelbrokerWebsocket() { | ||||
try { | try { | ||||
const tunnelbrokerSocket = new WebSocket('ws://localhost:51001'); | const tunnelbrokerSocket = new WebSocket('ws://localhost:51001'); | ||||
tunnelbrokerSocket.on('open', () => { | tunnelbrokerSocket.on('open', () => { | ||||
// TODO: Replace keyserver details with actual details | // TODO: Replace keyserver details with actual details | ||||
const message = { | const message: ConnectionInitializationMessage = { | ||||
type: 'sessionRequest', | type: 'sessionRequest', | ||||
accessToken: 'foobar', | accessToken: 'foobar', | ||||
deviceId: 'foo', | deviceId: 'foo', | ||||
deviceType: 'keyserver', | deviceType: 'keyserver', | ||||
}; | }; | ||||
console.log( | console.log( | ||||
'Sending message to tunnelbroker: ' + JSON.stringify(message), | 'Sending message to tunnelbroker: ' + JSON.stringify(message), | ||||
); | ); | ||||
Show All 16 Lines |