fixup(sync): code cleaning

This commit is contained in:
Yohan Boniface 2024-12-27 12:18:41 +01:00
parent fd8cc2a2cb
commit b7c2732407
2 changed files with 3 additions and 5 deletions

View file

@ -150,7 +150,6 @@ export class SyncEngine {
* and dispatches the different "on*" methods. * and dispatches the different "on*" methods.
*/ */
receive({ kind, ...payload }) { receive({ kind, ...payload }) {
console.log(kind, payload)
if (kind === 'OperationMessage') { if (kind === 'OperationMessage') {
this.onOperationMessage(payload) this.onOperationMessage(payload)
} else if (kind === 'JoinResponse') { } else if (kind === 'JoinResponse') {
@ -286,7 +285,6 @@ export class SyncEngine {
*/ */
sendToPeer(recipient, verb, payload) { sendToPeer(recipient, verb, payload) {
payload.verb = verb payload.verb = verb
console.log('Sending peermessage to', recipient)
this.transport.send('PeerMessage', { this.transport.send('PeerMessage', {
sender: this.uuid, sender: this.uuid,
recipient: recipient, recipient: recipient,
@ -486,7 +484,7 @@ export class Operations {
return ( return (
Utils.deepEqual(local.subject, remote.subject) && Utils.deepEqual(local.subject, remote.subject) &&
Utils.deepEqual(local.metadata, remote.metadata) && Utils.deepEqual(local.metadata, remote.metadata) &&
(!shouldCheckKey || (shouldCheckKey && local.key == remote.key)) (!shouldCheckKey || (shouldCheckKey && local.key === remote.key))
) )
} }
} }

View file

@ -25,8 +25,8 @@ class SyncConsumer(AsyncWebsocketConsumer):
# Join room group # Join room group
await self.channel_layer.group_add(self.map_id, self.channel_name) await self.channel_layer.group_add(self.map_id, self.channel_name)
await self.accept()
self.is_authenticated = False self.is_authenticated = False
await self.accept()
async def disconnect(self, close_code): async def disconnect(self, close_code):
await self.channel_layer.group_discard(self.map_id, self.channel_name) await self.channel_layer.group_discard(self.map_id, self.channel_name)
@ -37,7 +37,7 @@ class SyncConsumer(AsyncWebsocketConsumer):
await self.broadcast(message.model_dump_json()) await self.broadcast(message.model_dump_json())
async def broadcast(self, message): async def broadcast(self, message):
# Send to one all channels # Send to all channels (including sender!)
await self.channel_layer.group_send( await self.channel_layer.group_send(
self.map_id, {"message": message, "type": "on_message"} self.map_id, {"message": message, "type": "on_message"}
) )