From 7e5b3bf94d5e18007b1297b90af6e36509d5ac1a Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Tue, 20 Oct 2020 14:30:27 -0300 Subject: [PATCH] decode varint for incoming typeid of Schema messages. colyseus/colyseus#369 --- Assets/Plugins/Colyseus/Room.cs | 7 +++++-- Server/package.json | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Assets/Plugins/Colyseus/Room.cs b/Assets/Plugins/Colyseus/Room.cs index 27571d56..190c7329 100644 --- a/Assets/Plugins/Colyseus/Room.cs +++ b/Assets/Plugins/Colyseus/Room.cs @@ -274,10 +274,13 @@ protected async void ParseMessage (byte[] bytes) } else if (code == Protocol.ROOM_DATA_SCHEMA) { - Type messageType = Schema.Context.GetInstance().Get(bytes[1]); + Schema.Iterator it = new Schema.Iterator { Offset = 1 }; + var typeId = Decode.DecodeNumber(bytes, it); + Type messageType = Schema.Context.GetInstance().Get(typeId); var message = (Schema.Schema) Activator.CreateInstance(messageType); - message.Decode(bytes, new Schema.Iterator { Offset = 2 }); + + message.Decode(bytes, it); IMessageHandler handler = null; OnMessageHandlers.TryGetValue("s" + message.GetType(), out handler); diff --git a/Server/package.json b/Server/package.json index 2e6c63d5..6a17d416 100644 --- a/Server/package.json +++ b/Server/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@colyseus/social": "^0.10.0", - "colyseus": "^0.14.0-alpha.16", + "colyseus": "^0.14.0-alpha.19", "cors": "^2.8.5", "express": "^4.13.3", "express-jwt": "^5.3.1",