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

查看:30
本文介绍了如何在 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 对 op 说:我建议更新您的堆栈以使用我们刚刚发布的 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 也有一些身份验证,所以它不可能与普通的网络套接字一起使用.我建议您使用的只是一个 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天全站免登陆