is it possible to use flash sockets and websockets simultaneously with socket io?
I have been struggling with this for some days now, trying to find information everywhere but I couldn't solve it.
Basically, I have a flash client app and a browser - chrome based app connected to a socket io - nodejs serve instance.
As you know, Chrome works over websockets and my flash app works over flash sockets.
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.
Do you know any way to keep serving info via flash - node in flashsockets but also guarantee that node - chrome communicates via websockets?
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
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"
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 a lot for your help!
Have you tried to use different namespaces for separating websocket and flashsocket communication?
Hello chrmoritz and many thanks for your help.
No, I didn't. I didn't know that you used namespaces to solve my issue.
I will search how to do this!; if you have a good gist example or URL, that'd be very welcome.
Thanks a lot for your input!
chrmoritz, many thanks for pointing me in the right direction!
I have solved it by working in two different namespaces: one for the browsers and another for flash.
Example:
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 useful.
I hope this helps someone!
All the best, and thanks again chrmoritz!