Support `onMessage` parsing `Schema` messages sent from client to server
See original GitHub issueThe work @endel did for issue https://github.com/colyseus/colyseus/issues/315 is extremely useful for sharing Schema
s between the client and server for messages that the server sends to the client, and it would be great to have that same functionality available when sending messages from the client to the server.
Currently, everyone needs to manually implement parsing JSON messages from the client, which is error-prone and a hassle. Additionally, implementing this would let us benefit from using schema-codegen to keep message schemas the same between the client and server.
It could look something like this, similar to what’s listed in https://github.com/colyseus/colyseus/issues/315:
this.onMessage(MoveMessage, (client: Client, message: MoveMessage) => {
// Handle schema-encoded MoveMessage, while benefitting from autocompletion.
});
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Proposal: handle onMessage by message type #315 - GitHub
Hi @zgz682000, only the client-side is able to listen to Schema messages. The client-side is not allowed to send Schema messages so far,...
Read more >HTML5 Server-Sent Events and Examples - Sweetcode.io
In this article, we'll explore simple messaging with HTML5's SSE using a Java Servlet as the server and some JavaScript code in a...
Read more >Writing WebSocket client applications - Web APIs | MDN
Receiving messages from the server. WebSockets is an event-driven API; when messages are received, a message event is sent to the WebSocket ...
Read more >A JSON event-based convention for WebSockets - Thoughtbot
We get a message from the server, we add it to the page. We hijack a form's submit event and send its contents...
Read more >Chapter 5 Using Message-Driven Beans - Oracle Help Center
A client accesses a message-driven bean through JMS by sending messages to the message destination for which the message-driven bean class is the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @rnd256, thanks! I agree, let’s use this issue to track the progress on the documentation https://github.com/colyseus/colyseus/issues/433
I think this is still relevant - ideally the docs would cover this helpful feature