Skip to content

Commit

Permalink
chore: add more logs for debugging ws server (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtsukino authored Nov 6, 2024
1 parent ce18598 commit 76a1fa7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions server/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ wss.on('connection', (client: WebSocket, request: IncomingMessage) => {
console.log(`New Connection - ${clientId}`);

if (!clientId.includes(':proof')) {
console.log('proof connection', clientId);
client.send(
bufferify({
method: 'client_connect',
Expand All @@ -264,6 +265,7 @@ wss.on('connection', (client: WebSocket, request: IncomingMessage) => {
if (pair) {
pairs.delete(pair);
pairs.delete(clientId);
console.log('disconnect', clientId);
await send(
pair,
bufferify({
Expand All @@ -285,7 +287,10 @@ wss.on('connection', (client: WebSocket, request: IncomingMessage) => {
const [cid] = clientId.split(':');
const pairedClientId = pairs.get(cid);
// @ts-ignore
console.log('mpc', rawData.length);
console.log('mpc', rawData.length, {
from: clientId,
to: pairedClientId + ':proof',
});
await send(pairedClientId + ':proof', rawData);
return;
}
Expand Down Expand Up @@ -314,11 +319,11 @@ wss.on('connection', (client: WebSocket, request: IncomingMessage) => {
case 'proof_request_cancel':
case 'proof_request_reject':
case 'proof_request_end':
console.log(msg.method);
console.log(msg.method, { from: clientId, to });
await send(to, rawData);
break;
case 'pair_request_success': {
console.log(msg.method);
console.log(msg.method, { from: clientId, to });
if (await send(to, rawData)) {
pairs.set(to, clientId);
pairs.set(clientId, to);
Expand Down

0 comments on commit 76a1fa7

Please sign in to comment.