question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom message to Client?

See original GitHub issue

Hi, 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:closed
  • Created 10 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
michellecommented, Dec 10, 2013

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:

Hi, 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’, payload: { msg: id + ‘: Authorizaton Success’ } }));

            f(); // go on the rest
        }
        else
        {
            socket.send(JSON.stringify(
            {
                type: 'ERROR',
                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??

I’ve read #10 https://github.com/peers/peerjs-server/pull/10 by the way, but no clue. Thanks.

— Reply to this email directly or view it on GitHubhttps://github.com/peers/peerjs-server/issues/28 .

0reactions
michellecommented, Dec 11, 2013

Thanks for using us! 😃

Michelle

On Tue, Dec 10, 2013 at 2:33 PM, Ken OKABE notifications@github.com wrote:

Thanks again, Michelle.

peer.js is one of the best project around. Just in case you haven’t noticed, one of the major mobile company in Japan

Keep up the good work!

— Reply to this email directly or view it on GitHubhttps://github.com/peers/peerjs-server/issues/28#issuecomment-30275281 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Use Customized Messages For A Better Customer ...
1. Humanize Your Messages · Add images to message icons · Include customer's first name in your messages · Add buttons to redirect...
Read more >
Example: Writing custom messages for clients
Some organizations create custom plug-ins that contain extra client features, such as site-specific login messages or corporate branding and graphics. To ...
Read more >
Send Personalized Messages to Customers on Their Most ...
You can send a message based on their activity on your website, whether they make a purchase, or even if they simply engage...
Read more >
Example: Writing custom messages for clients - IBM
Example: Writing custom messages for clients ... You can create a branding plugin that shows a custom message in the user's "New contact"...
Read more >
15 Actionable Personalization Messages to Connect With Users
What Is Personalized Messaging in Digital Marketing? ... Personalization messaging uses customer data like past purchases, demographics, and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found