lance-gg / lance

Multiplayer game server based on Node.JS
https://lance-gg.github.io/
Apache License 2.0
1.56k stars 166 forks source link

Provide game which demonstrated chat-services integration #32

Open namel opened 7 years ago

namel commented 7 years ago

This is a feature request.

Request to provide a new sample game - which integrates chat services. Since chat services are outside the scope of Incheon, there is a need to demonstrate how someone might integrate an Incheon game with a third-party chat service.

Ulydev commented 7 years ago

I don't know if that's been done already, but it would be great to expose a simple event-based communication interface between the client and the server, something like network:on(event, callback) and network:send(event, data). This way, anyone could implement their own custom network systems such as the chat system you're talking about. It'd be as simple as sending a message to the server and then broadcast the message to all clients server-side.

namel commented 7 years ago

@Ulydev I like that idea. A low-level messaging API. I can imagine it being useful in many other cases besides chat. I'm thinking this should be a separate feature request though, because I still see value in a sample game demonstrating integration with third-party chat services.

OpherV commented 7 years ago

@Ulydev Actually we already have this using socket.io's interface. for example in Spaaace:

On the client this.socket.emit('requestRestart'); https://github.com/OpherV/spaaace/blob/master/src/client/SpaaaceClientEngine.js#L40

On the server socket.on('requestRestart', makePlayerShip); https://github.com/OpherV/spaaace/blob/d7dba3fa531e713688f7e48c36533c07677d7254/src/server/SpaaaceServerEngine.js#L49

I do feel like we need to wrap this in an Incheon API call, so that it works the same once we implement other transport methods like UDP