Open Lonri opened 3 years ago
Hi @Lonri, the schema structures should be used for the room's state (this.state
).
But if you are trying to send it as a message I suggest using .toJSON()
when sending the data:
// server-side
this.broadcast("type", schemaInstance.toJSON())
// client-side
room.OnMessage("type", (message) => {...});
Alternatively, you can send schema messages as well by doing this:
// server-side
this.broadcast(schemaInstance);
// client-side
room.OnMessage<ServerGameDataRules>((message) => {...});
Please let me know if this helps you out. Cheers!
Hi @endel, that makes total sense, I'll change my approach and try out your suggestions. Thank you so much for the fast reply!
Sorry for reviving this but did you get any luck here? Got the same issue. Changed to .JSON on server but still nah
You can make your ArraySchemaIEnumerable
in C# and MsgPack serializer will try to deserialize it as Array, also constructor accepting T[]
on type is expected.
I can't seem to get any ArraySchema to work, being it string, number or something else. I know there's this closed issue about an ArraySchema problem but updating to the latest versions of colyseus didn't fix it for me.
Am I being blind or is there still a bug?
What I'm using:
Schema class on the server:
Schema class on the client generated using schema-codegen:
Stack trace: