I'm finding a way to realtime messaging in iPhone SDK. iPhone Safari doesn't support Web socket. Apple push notification is working only on application is close. I want to make like chat program with real time. There is other way except web socket ?
It's likely that the next version of iOS (4.2) will add WebSockets support. iOS 4.2 should be out this month.
You might looked at Socket.IO if you control the server side too. Socket.IO is a JavaScript library for the client and server that uses the best communication transport that both ends support starting with native WebSockets, then a Flash based WebSockets fallback, then various long-poll/COMET options. The API on client and server sides is very much like the normal WebSockets API regardless of which underlying transport is used. It would allow you to use the WebSockets protocol when available and fall back to something that still works when you don't have WebSockets (without requiring you to use a different API).
You can do some of the traditional "comet" tricks like long-polling or a forever iframe, however I'm not sure any of those are as concise as WebSockets.
If you're looking for a paired client / server side library, I would look at Socket.IO.
Related
I have started to work with OpenThread with a Nordic DK.
I am working with the BLE/Thread coap example that I modified in order to be a FTD instead of a MTD. Also, on one of my devices, the CoAP is configured as a server.
I figured out that when I pushed the button nRF52840 DK board programmed as a CoAP server, the light of the other board changes which means that the otCoapSendRequest function works.
Isn't it supposed to only works on a client device ?
Is it a normal or just a small bug in the OpenThread function ?
I can't speak for OpenThread in particular, but it is common in CoAP that server functions are enabled in addition to client functions rather switching between client and server mode – so it's not unexpected that client features still work even though you enabled server features.
This is because CoAP is designed to have much code shared between client and server. The Web of Things architecture calls the resulting client-server nodes "servients" (server-clients).
Thanks for your answer.
I dug into the Nordic Code and found out that the CoAP init function creats services if the server mode is enable.
In my code I switch from server to client on a randomly elected main device and this switch seems not to remove the services, I guess this combine with what you said explains what I have.
I have an Arduino loaded with sensors connected to a Raspberry Pi. The Arduino passes all the data from the sensors to Raspberry.
Now I want to push all of these data in real-time over a socket to a server in the backend, and upload the data into a database.
I'm looking for the most optimal solution for this. Socket.io seems like a popular solution and relies on WebSockets and NodeJS.
Pusher seems like a decent API service that can easily integrate into iOS and Android devices.
What is the best solution out here? It seems like WebSocket is the way to go, but is there a better protocol to use for this purpose?
Check out the MQTT protocol as well. It's becoming widely used for this kind of purpose. You can find both open-source and commercial, as well as cloud-based and self-hosted, MQTT brokers.
I have an Arduino board in a location, and a webserver.
I also have a website that is supposed to control the Arduino. What technique would allow users to take control of the Arduino board with the least amount of latency?
I have Node.js, socketserver, Jabber in mind to experiment with, but is this the right direction?
You should have a look at Socket.IO for implementing WebSockets on server- and client-side.
There's a great project called duino for accessing Arduino with Node.js, you "only" have to pipe all communication through WebSockets.
Update: In the meantime I have published a framework for sending commands to an Arduino with Node.JS, JavaScript and WebSockets. Make sure to have a look at Noduino!
I had good luck using node-serialport to talk to the Arduino. Using the serial port results in very low latency, and I used it to build a photobooth. The code is on GitHub if you want to check it out, though it's very poorly organized as I was rushing to get this done for my wedding and well... corners were cut.
I'm looking to write my own multiplayer game server (most likely in nodejs) and I was wondering what protocol I should be using to transfer data? Are Datagrams the norm to send information (i realize they don't confirm delivery like HTTP, that can written on top of the protocol)? Any suggestions of performant proven systems would be a real help.
I guess I'm looking for successful techniques in handling the data transfer quickly and effectively (maintaining state on the server and scaling are a separate issue that I have a solid understanding of).
I'm looking to initially support desktop/mobile games (MacOS, iOS, and Android).
For all your protocol needs take a look at socketIO.
Basically your best solution is to rely on websockets which are TCP sockets. socketIO is just a nice cross-browser compliant abstraction.
Either you use standard long pulling techniques or html5 websockets. There is no access to UDP for browser <-> server.
There is a technology that is called RTMFP that Adobe introduced in the latest version of Flash (Flash 10). It allows you to do P2P connection and transfer data directly from a client to an other client without passing by the server. On top of that, it's using UDP to transfer data. I believe that this was originally designed to do video and audio streaming, but you can use it to pass data around.
However the main downside on this technology is the mobile since most of them don't support Flash. In this case you can use Socket.IO and use the server as a router of information as a fallback.
If you want to build your application in Javascript, you can still use it by bridging the functionnality to Javascript. If you want to take a look at a simple version of a bridge, you can take a look at this github project (I am the author).
As a C++ developer of Massive Multiplayer games for 10 years, I can tell you that most of your more advanced games, such as ones in which I was involved (Legends Of Kesmai, Magic: The Gathering Online, Airwarrior II, AVP, NTN Triva) to name a few, TCP is used for most communication simply because you need an ACK / NACK to be sure the data was received from the client. That is not to say UDP doesn't have it's place. In Legends we wrote the the protocol code to use UDP for out of bandwidth delivery of data which wasn't imperative that it be received in proper packet order and complete. Use UDP when you want to do things like update graphic files in the background while the user is playing, etc. This type of delivery is often used for such purposes and allows your TCP packets to arrive as required by your server.
Is it possible to create a real time game with node.js that requires twitch reflexes. How high is the latency? How low can it realistically go?
It is possible to make a real-time game in node.js as you could with any other language/framework.
The problem here would be what kind of server and client you would use.
Using the http server feature for such game would be a bad idea and very difficult, but you could use the TCP server (now called net server) as you would in any other language.
The client would be on some platform where you can use sockets, like Flash, Java applets or desktop software.
Please notice that even with using a TCP socket server you might have problems with latency for a twitch game, but this is outside the area related to this question and more about games and networking.
PS: You could use web sockets since they should theoretically work like TCP sockets but there isn't yet a good support for them in the current modern browsers.
EDIT:
It seems I haven't explained myself correctly, you can make a browser accessible game like you said, you just need to use a protocol that allows you to quickly send data back and forth in real time.
If you want a "pure" browser game without any third party plugins the only way, like I said before, is using JavaScript with websockets which is not well supported yet by the major browsers. (You could use a Flash bridge and still have your game in JavaScript though.)
Using a third party plugin you have Flash and Java (besides the numerous less known plugins like unity and so on). Both have TCP sockets (not sure about UDP) and can be made to connect to a node.js net server (with some security limitations). Most people would say for you to go with Flash since there is a bigger support but Apple doesn't like it so no Flash in iPhone/iPad/iPod Touch or on other miscellaneous mobile devices (that support Java instead).
So yeah... good luck with this.
EDIT 2:
Websocket support in browsers is now pretty decent so I recommend it for realtime games if you want to use the browser as a client.
HTTP servers are typically optimised for throughput/bandwidth over latency. node.js is unlikely to be an exception, and HTTP is intrinsically poor for low latency anyway due to the structure of the protocol.
One informal benchmark using node.js supports this, showing latencies of hundreds of milliseconds. By comparison most twitch games support latencies of no more than 30 or 40ms, ideally less.
Therefore I'd recommend dropping the twitch aspect if you can't drop HTTP.
It's possible, but it depends on how much data must be transmitted between server and client and how fast (speaking of latency). Take a look at Sousaball by Creationix, for example.
Also, if you plan to use websockets, take a look at Socket.IO library by learnboost. It uses websockets when available and falls back to comet in other cases.