8

The new iOS websocket library, SocketRocket, looks really awesome, and the chat example project is really sweet. The example chat server is written in Python, of which I know none. I'm slightly familiar with socket.io on node.js and prefer to try javascript. I tried connecting the SocketRocket TestChat simulator app to the node.js(6.10) socket.io(0.8.7) but the connection was refused. (Also, I'm not a node expert either, so this may be a silly question).

In a recent answer to an SO question, mikelikespie said to op: "I suggest updating your stack to use the iOS WebSocket library we just released."

What does that mean exactly? What is necessary to get the SocketRocket library to talk to a node socket.io server? Any sample code or suggestions are greatly appreciated.

4

3 に答える 3

9

socket.io には、websocket やロング ポーリングなどのトランスポート プロトコルに基づいて構築された独自のプロトコルがあります。Socket.io にもいくつかの認証があるため、通常の Web ソケットでは使用できません。使用することをお勧めするのは、単なる websocket サーバーであり、それ以上のものではありません。wsなど、互換性があるはずです。他にもライブラリはありますがws、現在活発に開発されており、他のライブラリよりも新しいと思います。

クライアント側の socket.io 互換性を持たせることもできますが、その必要はないと思います。その仕様は次のとおりです: https://github.com/LearnBoost/socket.io-spec

私が助けてくれることを願っています。

于 2012-02-16T17:45:52.080 に答える
3

GitHubの socket.IO-objcは成熟した Socket.IO / Objective C Library のようです

SocketRocket を使用して、websocket 接続を処理します。

これにより、古いブラウザー (ロング ポーリングなどに劣化) をサポートするソケット サーバーを使用できるようになり、SocketRocket 経由で iOS アプリに引き続きアクセスできます。

于 2013-05-02T12:33:21.807 に答える