是否有可能同时使用闪光灯插座和WebSockets的带插座的IO? [英] is it possible to use flash sockets and websockets simultaneously with socket io?

查看:179
本文介绍了是否有可能同时使用闪光灯插座和WebSockets的带插座的IO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力奋斗着这个现在一些日子,试图到处找资料,但我不可能解决这个问题。

I have been struggling with this for some days now, trying to find information everywhere but I couldn't solve it.

基本上,我有一个Flash客户端应用程序和浏览器 - 铬基于应用程序连接到插座IO - nodejs服务实例

Basically, I have a flash client app and a browser - chrome based app connected to a socket io - nodejs serve instance.

如你所知,Chrome浏览器的工作原理过的WebSockets和我的Flash应用程序的工作原理在闪光灯插座。

As you know, Chrome works over websockets and my flash app works over flash sockets.

一切运作良好的镀铬和节点之间,但是当我提出从我的Flash应用程序交互,这降低了连接类型闪烁插座代替的WebSockets使Chrome网上应用程序无法从服务器读取,作为服务器开始使用flashsockets发出的消息。基本上,当我从flash交互,Chrome不接收任何信息了。

Everything works well between chrome and node, but when I make any interaction from my flash app, that degrades the connection type to flash sockets instead of websockets making the chrome web app unable to read from the server, as the server starts to emit messages using flashsockets. Basically, when I do any interaction from flash, chrome doesn't receive any info any more.

你知道任何方式通过闪光来保持服务信息 - 在flashsockets节点,但也保证节点 - 铬通过WebSockets的通信

Do you know any way to keep serving info via flash - node in flashsockets but also guarantee that node - chrome communicates via websockets?

我曾尝试进行连接带插座的IO可以在插座IO网站上找到推荐的库;它是这个 https://github.com/simb/FlashSocket.IO

I have tried the recommended library for connectivity with socket io that you can find in the socket io website; it is this one https://github.com/simb/FlashSocket.IO

此外,我曾尝试使用一个库中使用的WebSockets AS3,但似乎uncapable与socket.io正常通信;它是这个 https://github.com/y8/websocket-as 。 IO尝试连接时输出的信息插座是调试 - 摧毁non-socket.io升级

Also I have tried to use a library in AS3 that uses websockets, but seems uncapable of communicating properly with socket.io; it is this one https://github.com/y8/websocket-as . The message socket io outputs when trying to connect is "debug - destroying non-socket.io upgrade"

某些调试code在这里,显示flashsockets和WebSocket的,这是我的两个客户端应用程序试图连接到同一个套接字IO服务器:

Some debug code here, showing flashsockets and websocket, this is, my two client apps trying to connect to the same socket io server:

https://gist.github.com/4637617

非常感谢您的帮助!

推荐答案

谢谢,最后大量的工作后,我设法解决这个问题。

Thanks, finally after a lot of work, I have managed to solve the problem.

Socket.io有一个非常聪明的实现,它允许您使用的命名空间和客房。

Socket.io has a very smart implementation that allows you to use namespaces and rooms.

我已经在两个不同的命名空间的解决了这个问题:一个是浏览器,另一个用于闪存

I have solved it by working in two different namespaces: one for the browsers and another for flash.

例如:

 var browser = io.of("/browser").on('connection', function (socket) {
     socket.on('move', function (data) {
        browser.emit("move", {"left" : data.left, "top" : data.top});
     });
 });

 io.sockets.on('connection', function (socket2) {
     socket2.on('click', function (data) {
        browser.emit("move", {"left" : 1000, "top" : 50});
    });
 });

闪光灯发送点击当我点击一个按钮,然后将消息发送给所有的浏览器在浏览器中的命名空间。

Flash sends "click" when I click a button and then I send a message to all the browsers in the browser namespace.

pretty的有用。

Pretty useful.

我希望这可以帮助别人!

I hope this helps someone!

所有最优秀的

这篇关于是否有可能同时使用闪光灯插座和WebSockets的带插座的IO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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