Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7940117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:17:36+00:00 2026-06-03T23:17:36+00:00

I have a WebSocket connection set up for a basic web chat server. Now,

  • 0

I have a WebSocket connection set up for a basic web chat server.

Now, whenever a message is received, it is sent to a function which outputs it on the screen.

socket.onmessage = function(msg){output(msg);}

However, there are certain technical commands which the user can send to the server through the connection which elicit a technical response, not meant to be output on the screen.

How can I grab the server response which immediately follows one of these technical messages?

Do I put a separate socket.onmessage right after the block of code which sends the technical message? I imagine that would take all future messages. I just want the next one.

Ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:17:37+00:00Added an answer on June 3, 2026 at 11:17 pm

    You can packetise the data, I mean, by a special character/s, form a string like this :

    "DataNotToBeShown"+"$$"+"DataToBeShown"; //if $$ is separating character
    

    And then, you can split the string in javascript like this :

    var recv=msg.data.split('$$');
    

    So, the data not be shown is in recv[0] and data to be shown, in recv[1]. Then use however you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a socket server in php server.php $master = WebSocket(localhost,800); $sockets = array($master);
If you have a complex requirement set with many users(&servers) how will your websocket
I used to have a small chat app(which was almost working), that uses PHP,
I have browser client Javascript which opens a WebSocket (using socket.io) to request a
I'm using Express.js to create a server to which I can connect using web
i did implement a websocket server in libevent and while i dont have any
I currently have a WebSocket server (C#) and a client (JavaScript / HTML5). This
I have lost somehow connection to the world of web programming six years back
What i want to be able to do is have a server which one
I have Chromium 12.0.742.112 (90304) and I'm trying to set up a simple WebSocket

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.