Custom message to Client?
See original GitHub issueHi, basically, I’d like to implement AUTH bootstrap in server.js PeerServer.prototype._initializeWSS such as
if (true) // true for auth passed
{
socket.send(JSON.stringify(
{
type: 'SUCCESS', //got WARNING You received an unrecognized message: [object Object]
payload:
{
msg: id + ': Authorizaton Success'
}
}));
f(); // go on the rest
}
else
{
socket.send(JSON.stringify(
{
type: 'ERROR', //works fine as it is
payload:
{
msg: id + ': Authorizaton Failed'
}
}));
socket.close();
return;
}
However, in this sample, I tried type: ‘SUCCESS’ and which is unrecognized message at client side. WARNING You received an unrecognized message: [object Object]
Having googled for a while to find definition of the type, I could not find them. All the type I can find in the server.js code is type: ‘ERROR’, type: ‘ID-TAKEN’, and type: ‘OPEN’ seems to do nothing.
I need to grab a server status for my own implementation in the context of the Connection status: http://cdn.peerjs.com/demo/chat.html
How can we do this?? The types must be defined somewhere in the code, but somehow I can’t find it, so please advise.
I’ve read https://github.com/peers/peerjs-server/pull/10 by the way, but no clue. Thanks.
Issue Analytics
- State:
- Created 10 years ago
- Reactions:1
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
Hey Ken,
You’ll have to edit the server and client side code to recognize those messages. If you’ll notice, we switch on the message type to decide how to process the message on both sides. Since SUCCESS is not yet a recognized type, you’re getting that message.
Michelle
On Tue, Dec 10, 2013 at 12:16 AM, Ken OKABE notifications@github.comwrote:
Thanks for using us! 😃
Michelle
On Tue, Dec 10, 2013 at 2:33 PM, Ken OKABE notifications@github.com wrote: