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 8223659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:47:03+00:00 2026-06-07T14:47:03+00:00

if have standard socket.io setup: var app = require(‘http’).createServer().listen(80,’127.0.5.12′), io = require(‘socket.io’).listen(app); session =

  • 0

if have standard socket.io setup:

var app = require('http').createServer().listen(80,'127.0.5.12'),
io = require('socket.io').listen(app);

session = require('./local_modules/session.js');

// creating a new websocket to keep the content updated without any AJAX request
io.sockets.on('connection', function(socket) {

  // session, login, logout
  socket.on( 'session', session.session.bind(socket) );
  socket.on( 'login', session.login.bind(socket) );
  socket.on( 'logout', session.logout.bind(socket) );

  // what to add new listener here!
});

later in the program, once it knows what it wants to do, it wishes to add new functionality to the socket listener. for example, in the middle of ‘session’ might wish to add ‘something-new’:

exports.session = function( sid) {
  var socket = this;
  ...
  // everything cool, now want to add 'something-now' to socket
  // do I simply - will something simple as this work?
  socket.on( 'something-new', session.something_new.bind(socket) );
}

exports.something_new = function( arg ) {
}

is this correct – it just seems wrong?

  • 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-07T14:47:06+00:00Added an answer on June 7, 2026 at 2:47 pm

    If you just want to call ‘whatever.func()’ on the socket event ‘something-new’

    socket.on('something-new', whatever.func(data) );
    

    or

    socket.on('something-new', function(data){
      whatever.func(data);
      whatelse.func(data.someproperty);
    });
    

    should work, while ‘data’ is the first argument passed, when emitting ‘something-new’.

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

Sidebar

Related Questions

I have a C++ app that uses standard socket calls and I want to
I have a program in C++, using the standard socket API, running on Ubuntu
Well I have been wondering if there is a standard socket header file for
I have a regular TCP socket connection between a Node.js application (using standard net.Socket
I have standard source code package under Linux which requires to run ./configure make
I've heard they have standard GUI guideline, but I can't seem to find a
I have a mobile site running with jQuery Mobile. I want to have standard
I have a standard textbox and I've got jQuery on the page. I want
I have a standard ASP.NET 2.0 web page with a Delete button on it.
I have a standard (I think) web project developed with the eclipse IDE. I

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.