如何在socket.io中使用SocketRocket? [英] How to use SocketRocket with socket.io?

查看:189
本文介绍了如何在socket.io中使用SocketRocket?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的iOS websocket库, SocketRocket ,看起来非常棒,聊天示例项目真的很棒甜。示例聊天服务器是用Python编写的,我不知道。我对node.js上的socket.io稍微熟悉,并且更喜欢尝试使用javascript。我尝试将SocketRocket TestChat模拟器应用程序连接到node.js(6.10)socket.io(0.8.7),但连接被拒绝。 (另外,我也不是节点专家,所以这可能是一个愚蠢的问题。)

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).

在最近回答SO 问题,mikelikespie对操作说:我建议更新你的堆栈以​​使用iOS我们刚刚发布的WebSocket库。

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."

这究竟是什么意思?有什么必要让SocketRocket库与节点socket.io服务器通信?非常感谢任何示例代码或建议。

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.

推荐答案

嗯,你的socket.io有自己的协议,建立在诸如websockets之类的传输协议上或者长轮询,SocketRocket只是一个websocket库,没有了。 Socket.io也有一些身份验证,因此使用普通的Web套接字是不可能的。我建议你使用的只是一个websocket服务器,仅此而已。如 ws ,应该兼容。还有其他库,但是, ws 我认为目前正在积极开发,并且比其他库更新。

Well you socket.io has it's own protocol built on transport protocols such as websockets, or long polling, well SocketRocket is just a websocket library, no more. Socket.io also has some authentication, so it's not possible to use it, with normal web sockets. What I suggest you to use is a just websocket server, no more than that. Such as ws, which should compatible. There are other libraries, but, ws I believe is actively developed at the moment, and newer than others.

你也可以使你的客户端socket.io兼容,但我认为它没有用。以下是它的规格: https://github.com/LearnBoost/socket.io-spec

You can also make your clientside socket.io compatible, but I think its uneeded. Here's the specs for it: https://github.com/LearnBoost/socket.io-spec

希望我帮忙。

这篇关于如何在socket.io中使用SocketRocket?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆