Sending a message from a different (non socket.io) client

598 views
Skip to first unread message

Matt

unread,
Dec 28, 2010, 7:29:37 PM12/28/10
to Socket.IO
I have a C#/.NET client that I want to ferry messages through the
node.js server that is running Socket.IO. The C# client connects with
web-sockets, and the nodejs server will simply pass them back up to
the the web based clients.

I've been able to establish and upgrade the websocket connection, and
can see as much through some console debugging statements in
Socket.IO. But I cannot seem to get actual messages/content sent
through the connection.

Is there a specific json string that is expected? e.g. {'message':
'my content here'}, or does Socket.IO simply expect some kind of
string data in the message?

Right now, through my socketed connection I am sending

0x00 + my string message + 0xFF

And then flushing the stream.

But my client.on('message', function(){}) listener in my nodejs server
code never seems to be hit. It hits just fine when I make the call
from the web-based Socket.IO client (my code used the 'chat' room
example as a foundation to build on). So, I know the server *can*
receive messages, but the messages sent from my own client don't
trigger the listener. Am I missing something obvious here?

regards,
Matt

Guillermo Rauch

unread,
Dec 28, 2010, 8:23:58 PM12/28/10
to sock...@googlegroups.com
Look at util.encode and util.decode. 
--
Guillermo Rauch
http://devthought.com

Matt

unread,
Dec 29, 2010, 11:26:06 AM12/29/10
to Socket.IO
Thanks Guillermo. For anyone else who stumbles on this, my quick
tests show this is working:

"testing, 123" ==> "~m~11~m~testing 123"
{"foo":"bar", "a":1} ==> '~m~22~m~~j~{"foo":"bar","a":1}'

-Matt
Reply all
Reply to author
Forward
0 new messages