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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:07:41+00:00 2026-05-27T21:07:41+00:00

I have an application where I want to use node.js and now.js to share

  • 0

I have an application where I want to use node.js and now.js to share the state of an object within a nowjs “group” across any number of clients.

As an example of what I’m trying to do, let’s say that within the multiroom chat example that comes with now.js, there could be any number of rooms, with the ID chosen by the user. If the user knows the ID, they can enter (or be the first to “create”) that room. There is a “history” object that is maintained for each room once it is created and communication starts happening. The history object contains a property or two, and an array of comment objects, each with a user property, a comment property, and a datetime property. When a new user connects, they should immediately have access to the history.

Is there a way to store a group-scoped object variable on the server to sync with? Am I thinking about this in the wrong way? Am I crazy or a little slow?

  • 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-27T21:07:41+00:00Added an answer on May 27, 2026 at 9:07 pm

    OK…I got it.

    I have a new function createHistory(groupid) on the server side, which returns a new history object if it doesn’t already exist when the user enters the room(group). This would occur if this user just created the room.

    This history object employs add, remove and list methods. Since I need to get at the list from the client, it’s important that I use a callback like the following:

    api.get = (callback) ->
      callback(_history)
    

    I assign the result:

    everyone.getGroup(this.now.groupid).now.history = createHistory(this.now.groupid)
    

    Now I can add history at the server:

    api.add = (time,user,text) ->
      _history.items.push {time:time, user:user,text:text}
    

    And get to it from my client:

    now.history.get (history) ->
      for item in history
        #do something...
    

    The only drawback is once the room is empty, the history evaporates…I think. Although I suppose you could check for the last disconnect and persist it somewhere if you wanted.

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

Sidebar

Related Questions

I have an application which doesn't use ARC. Now I want to integrate twitter
I have a .NET application that I want to use as a client to
I want to write a web application and want to use Ruby. I have
i have application who use specific process during running and i want to sample
I have a non-rails application that I want to use rails active-record migrations with.
I have configuration entity in my .NET CF application and I want to use
I want to use bar chart in web application. I have searched many libraries
I have a java main application, and I want to use log4j. I don't
I have a Java-JSF Web Application on GlassFish, in which I want to use
Scenario I have a windows forms application. I want to use two different WCF

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.