sam-coder-cli 1.0.27 → 1.0.28
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 +29 -0
- package/package.json +1 -1
|
@@ -695,9 +695,38 @@ class MultiplayerClient extends EventEmitter {
|
|
|
695
695
|
disconnect() {
|
|
696
696
|
if (this.ws) {
|
|
697
697
|
this.ws.close();
|
|
698
|
+
this.connected = false;
|
|
699
|
+
this.ws = null;
|
|
700
|
+
}
|
|
701
|
+
if (this.rl) {
|
|
702
|
+
this.rl.close();
|
|
698
703
|
}
|
|
699
704
|
}
|
|
700
705
|
|
|
706
|
+
sendChatMessage(message) {
|
|
707
|
+
if (!this.connected || !this.ws) {
|
|
708
|
+
console.error('Not connected to server');
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
try {
|
|
713
|
+
const chatMessage = {
|
|
714
|
+
type: 'chat_message',
|
|
715
|
+
sessionId: this.sessionId,
|
|
716
|
+
clientId: this.clientId,
|
|
717
|
+
sender: this.name,
|
|
718
|
+
message: message,
|
|
719
|
+
timestamp: new Date().toISOString()
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
this.ws.send(JSON.stringify(chatMessage));
|
|
723
|
+
return true;
|
|
724
|
+
} catch (error) {
|
|
725
|
+
console.error('Error sending chat message:', error);
|
|
726
|
+
return false;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
701
730
|
getClientName(clientId) {
|
|
702
731
|
if (!clientId) return 'Unknown';
|
|
703
732
|
const client = this.clients.find(c => c.clientId === clientId || c.id === clientId);
|