sam-coder-cli 1.0.20 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/multiplayer-client.js +35 -0
- package/package.json +1 -1
|
@@ -650,6 +650,41 @@ class MultiplayerClient extends EventEmitter {
|
|
|
650
650
|
const client = this.clients.find(c => c.clientId === clientId || c.id === clientId);
|
|
651
651
|
return client ? (client.name || client.clientInfo?.name || 'Unknown') : 'Unknown';
|
|
652
652
|
}
|
|
653
|
+
|
|
654
|
+
createSession() {
|
|
655
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
656
|
+
throw new Error('Not connected to server');
|
|
657
|
+
}
|
|
658
|
+
this.sessionId = uuidv4();
|
|
659
|
+
this.isHost = true;
|
|
660
|
+
this.send({
|
|
661
|
+
type: 'create_session',
|
|
662
|
+
sessionId: this.sessionId,
|
|
663
|
+
clientInfo: {
|
|
664
|
+
name: this.name,
|
|
665
|
+
role: this.role,
|
|
666
|
+
model: this.model
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
return this.sessionId;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
joinSession(sessionId) {
|
|
673
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
674
|
+
throw new Error('Not connected to server');
|
|
675
|
+
}
|
|
676
|
+
this.sessionId = sessionId;
|
|
677
|
+
this.isHost = false;
|
|
678
|
+
this.send({
|
|
679
|
+
type: 'join_session',
|
|
680
|
+
sessionId: this.sessionId,
|
|
681
|
+
clientInfo: {
|
|
682
|
+
name: this.name,
|
|
683
|
+
role: this.role,
|
|
684
|
+
model: this.model
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
}
|
|
653
688
|
}
|
|
654
689
|
|
|
655
690
|
module.exports = MultiplayerClient;
|