I took the php code from the URL above, added in a CORS header, which is really nice because I can pretty much guarantee that it'll be coming from the game, and ran my project.
To my amazement, I started receiving messages from the php script.
message: This is a message at time 2019-05-29T13:46:09-0400
ping at 2019-05-29T13:46:10-0400
ping at 2019-05-29T13:46:11-0400
ping at 2019-05-29T13:46:12-0400
ping at 2019-05-29T13:46:13-0400
ping at 2019-05-29T13:46:14-0400
ping at 2019-05-29T13:46:15-0400
ping at 2019-05-29T13:46:16-0400
message: This is a message at time 2019-05-29T13:46:16-0400
ping at 2019-05-29T13:46:17-0400
ping at 2019-05-29T13:46:18-0400
ping at 2019-05-29T13:46:19-0400
ping at 2019-05-29T13:46:20-0400
Now normally, web hosts force php scrips to crash and burn after a set time. This one, 30 minutes later, is still sending pings to my C3 game client. So, either my host has lost their mind or,
The only downside 2 downsides I can find to this so far is that:
- It doesn't work in Edge and IE browsers (which I can certainly live with since IE is dead and Edge is switching to Chromium).
- It's not duplex, it's a one way communication from the server to the client. BUT - Ajax requests to send in chats from the client and server-sent events to feed out the chats should work.
- When running the php script above on Apache it opens a new process for every single client that connects. You get 1000 clients and you turned your server into goo again. A huge drawback.
Now, according to this post:
Node.js should be able to handle server-sent events with just one process and have thousands of clients connected.
Anyone else played with server-sent events? Any thoughts?