colyseus / colyseus-unity-sdk

⚔ Colyseus Multiplayer SDK for Unity
https://docs.colyseus.io/getting-started/unity-sdk/
MIT License
371 stars 102 forks source link

Not obviously: I need restart server, when getting message "Local schema mismatch" #129

Closed IlyaVorozhbit closed 3 years ago

IlyaVorozhbit commented 4 years ago

Hi!

I have added a few schema's to project, and when I tried to connect to server got an error, so I should use npx schema-codegen. I used it in another tab, and expected behaviour: it should work. But no, but when I terminated the server and start it again - problem disappear.

Its expected, that I need restart it? Can I open new PR, or I dont understand something?

Thanks

ps. line in code: https://github.com/colyseus/colyseus-unity3d/blob/30c9b7d8e8259a7516fafcbd26179a0ab6a91ec9/Assets/Plugins/Colyseus/Serializer/SchemaSerializer.cs#L58

endel commented 3 years ago

Hi @IlyaVorozhbit, yes, ideally you should restart the server every time you make a change on it. On the latest create-colyseus-app templates I've added the ts-node-dev tool which does that automatically for you:

Install the ts-node-dev package:

npm install --save-dev ts-node-dev

Use it as your start script:

{
  "scripts": {
    "start": "ts-node-dev src/index.ts"
  }
}