colyseus / colyseus-construct3

⚔ Colyseus Multiplayer SDK for Construct 3
https://docs.colyseus.io/getting-started/construct3-client/
MIT License
22 stars 12 forks source link

fix RoomSendJSON #25

Closed raassh-23 closed 1 year ago

raassh-23 commented 1 year ago

With the current version, trying to call Send JSON Message action will result in the following error

Uncaught (in promise) TypeError: this.RoomSend is not a function
    at ColyseusInstance.RoomSendJSON (3b76d90e-53bb-40a9-9c31-11f0e34ce5c6:56:12)
    at Action._RunObject_AllParamsVary (action.js:26:152)
    at EventBlock._RunActions_Fast (eventBlock.js:26:208)
    at EventBlock._RunAndBlock (eventBlock.js:24:415)
    at EventBlock.Run (eventBlock.js:21:393)
    at EventBlock._RunSubEvents_Fast (eventBlock.js:30:504)
    at EventBlock._RunSubEvents (eventBlock.js:29:259)
    at EventBlock._RunAndBlock (eventBlock.js:24:441)
    at EventBlock.Run (eventBlock.js:21:393)
    at EventSheet._ExecuteTrigger (eventSheet.js:19:154)

Looking briefly at the code, it seems like this is caused by one of those 'this' quirks of javascript. I'm not too familiar with C3 addon development, but i tried to fix it and i think this fix should work.

endel commented 1 year ago

Thank you for the PR @raassh-23! Just released new version with your fix.