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.
*/
receive({ kind, ...payload }) {
console.log(kind, payload)
if (kind === 'OperationMessage') {
this.onOperationMessage(payload)
} else if (kind === 'JoinResponse') {
@ -286,7 +285,6 @@ export class SyncEngine {
*/
sendToPeer(recipient, verb, payload) {
payload.verb = verb
console.log('Sending peermessage to', recipient)
this.transport.send('PeerMessage', {
sender: this.uuid,
recipient: recipient,
@ -486,7 +484,7 @@ export class Operations {
return (
Utils.deepEqual(local.subject, remote.subject) &&
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
await self.channel_layer.group_add(self.map_id, self.channel_name)
await self.accept()
self.is_authenticated = False
await self.accept()
async def disconnect(self, close_code):
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())
async def broadcast(self, message):
# Send to one all channels
# Send to all channels (including sender!)
await self.channel_layer.group_send(
self.map_id, {"message": message, "type": "on_message"}
)