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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:10:10+00:00 2026-05-26T16:10:10+00:00

I have a little WebSocket chat demo that I am working on ( based

  • 0

I have a little WebSocket chat demo that I am working on (based on this code). However, the part that doesn’t seem to be working is when a connection is closed between a client and the server, I want to notify all the subscribers that the user has “left the chatroom”. I thought that the server would be notified/run the onclose function when the client connection was dropped, but maybe that’s not how WebSockets work.

Here’s my EventMachine code:

  ws.onclose do
    puts "Connection closed"
    ws.send ({:type => 'status', :message => "#{@subscribers[subscriber_id]} has left the chatroom"}.to_json)
    @main_channel.unsubscribe(subscriber_id)
  end
  • 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-26T16:10:11+00:00Added an answer on May 26, 2026 at 4:10 pm

    You are trying to send data to a WebSocket that was just closed, that won’t work. You probably want to just push a message to the Queue like:

    ws.onclose do
      puts "Connection closed"
      msg = {:type => 'status', :message => "#{@subscribers[subscriber_id]} has left the chatroom"}.to_json
      @main_channel.push(msg)
      @main_channel.unsubscribe(subscriber_id)
    end
    

    That way the message will be send to all subscribers.

    Best regards

    Tobias

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

Sidebar

Related Questions

I have little working knowledge of python. I know that there is something called
I have little question about how web browser retrieve webpage? I know this User
I have little problem with a replacement of a little part in an url.
I have little question. I found this on internet: Type t = typeof(MyClass); MethodInfo[]
I have little code like: using (WebClient wc = new WebClient()) { wc.Proxy =
I have little problem in my iPhone application code but can not identify. please
I have little notification divs that should appear above the navigation. I tried other
This looks very simple but I have little experience with jQuery and I can't
I have little issue with detecting internet connection while using static IP on device.
I have little knowledge with the iPhone SKD (don't even know what code it

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.