Is there a way to have a live connection (like for a chat server) with a server using only HTML(5)/JavaScript?
+1
A:
Due to the nature of HTTP (only clients can start requests), you would need a "Push" server (aka Comet) on the server-side. You'd still only need JS on the client. See:
- HTTP Streaming for an explanation of the technology
- APE: Ajax Push Engine for usable implementation
- Comet Daily for news on Comet
This can also be implemented with a periodic refresh (polling) if you can't install a Comet engine on the server.
NullUserException
2010-10-01 15:36:17
A:
Yup. AJAX and some server code to handle messages updates is all you need to create just such a system. As @NullUserException noted, something like Comet might make this easier.
Stefan Kendall
2010-10-01 15:38:19
ajax just loads pages, I need a truly live "socket" connection.
Bubby4j
2010-10-01 15:43:02
You could emulate it. You don't need a live socket to do a chat client. Look at facebook chat; the order of messages isn't guaranteed, but that's because it shows the user's post as soon as they hit enter, rather than when the response returns.
Stefan Kendall
2010-10-01 17:57:55
And ajax doesn't just "load pages". It would allow you to make network requests to some server application which would manage reads and writes of the current chat session.
Stefan Kendall
2010-10-01 17:59:00
I'm trying to make a virtual world without using flash or any downloads.
Bubby4j
2010-10-04 19:10:43
And? If you want to do something like an MMO, you could buffer the actions of other players on the screen, so long as they couldn't conflict with your actions. I don't know that you could implement the efficient network protocol you would need to do a massive real-time game, however.
Stefan Kendall
2010-10-04 19:29:40
Ok, thanks. I guess this will work until they invent something better rofl.
Bubby4j
2010-10-06 15:10:52
+1
A:
Apparently FF4, Chrome, and Safari all support Web Sockets.
Here's a firefox example, although I'm not sure the spec is completely finalized yet.
Stefan Kendall
2010-10-06 16:13:18