Skip to content

Commit 76a1fa7

Browse files
authored
chore: add more logs for debugging ws server (#36)
1 parent ce18598 commit 76a1fa7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

server/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ wss.on('connection', (client: WebSocket, request: IncomingMessage) => {
244244
console.log(`New Connection - ${clientId}`);
245245

246246
if (!clientId.includes(':proof')) {
247+
console.log('proof connection', clientId);
247248
client.send(
248249
bufferify({
249250
method: 'client_connect',
@@ -264,6 +265,7 @@ wss.on('connection', (client: WebSocket, request: IncomingMessage) => {
264265
if (pair) {
265266
pairs.delete(pair);
266267
pairs.delete(clientId);
268+
console.log('disconnect', clientId);
267269
await send(
268270
pair,
269271
bufferify({
@@ -285,7 +287,10 @@ wss.on('connection', (client: WebSocket, request: IncomingMessage) => {
285287
const [cid] = clientId.split(':');
286288
const pairedClientId = pairs.get(cid);
287289
// @ts-ignore
288-
console.log('mpc', rawData.length);
290+
console.log('mpc', rawData.length, {
291+
from: clientId,
292+
to: pairedClientId + ':proof',
293+
});
289294
await send(pairedClientId + ':proof', rawData);
290295
return;
291296
}
@@ -314,11 +319,11 @@ wss.on('connection', (client: WebSocket, request: IncomingMessage) => {
314319
case 'proof_request_cancel':
315320
case 'proof_request_reject':
316321
case 'proof_request_end':
317-
console.log(msg.method);
322+
console.log(msg.method, { from: clientId, to });
318323
await send(to, rawData);
319324
break;
320325
case 'pair_request_success': {
321-
console.log(msg.method);
326+
console.log(msg.method, { from: clientId, to });
322327
if (await send(to, rawData)) {
323328
pairs.set(to, clientId);
324329
pairs.set(clientId, to);

0 commit comments

Comments
 (0)