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

  • Home
  • SEARCH
  • 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 6029493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:53:40+00:00 2026-05-23T04:53:40+00:00

I have designed this server to broadcast to all clients when it has to

  • 0

I have designed this server to broadcast to all clients when it has to and broadcast to specific clients when it has to.
I started working on client code to connect to it based on the arguments set in there but i got a mixed up at the point when client A is supposed to connect when a message is meant for client A or client B needs to connect based on that argument.
Below is the server code. A client pseudo code will be appreciated. thanks

//send messages to game clients and forward to bay 
var socket_cl = io.listen(server);     
    socket_cl.on('connection', function (client) {
        client.on('message', function (data) {
            broadcast(data); // broadcast to all clients
            // OR
            //search for kiosk / the right kiosk for machine which sent message
            //to be forwarded bayboard client
            //after this find the location of that kiosk and send
            JSON.parse(data);
            if (data.type == 'bb_message') {
                var kiosk = readerEngine.getKiosk(client.request.socket.remoteAddress);
                bayboard_location_map[kiosk.location_id].send(data.message);
            }
            socket.clients[id].send(data); //send message to bayclients
        });
        client.on('disconnect', function () {
            console.log('Client Disconnected.');
        });
  • 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-05-23T04:53:41+00:00Added an answer on May 23, 2026 at 4:53 am

    I think you mean you want to send data to a particular client? Your server code looks like its going to do a lookup based on an id that you pass from the client?

    Such that:

    // Client side
    if ( we want to send to a particular client ) {
        socket.send({destination: desination_id, payload: payload});
    } else {
        socket.send({destination: 'all', payload: payload});
    }
    
    // Server side
    client.on('message', function (data) {
        if (data.destination == 'all') {
            socket.broadcast(data.payload);
        } else {
            var destination = lookupDestination(data.destination);
            destination.send(data.payload)
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For learning purposes I am writing a socket based client/server application. I have designed
For learning purposes I am writing a socket based client/server application. I have designed
I have SQL Server 2008 with a table called ProductCategories designed like this: Id
I have designed this gui in netBeans which has a canvas , a couple
I have designed one sign-up form,in this form after getting all necessary values I
I am maintaining an application which has been designed like this: messy code --abuses-->
i m relatively new in Objective C, i have designed a server-client application and
I have a SQL Server database designed like this : TableParameter Id (int, PRIMARY
I have been developing a project and in this project i have designed my
My question is this: I have an application designed for iPhone and I decided

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.