Skip to content

Commit

Permalink
decode varint for incoming typeid of Schema messages. colyseus/colyse…
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Oct 20, 2020
1 parent 54fe267 commit 7e5b3bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Assets/Plugins/Colyseus/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7e5b3bf

Please sign in to comment.