Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reference for learning web socket [closed]

I want to write a web socket client in javascript and web socket server in ruby.

Where shall I start? are there any existing libraries to reduces my work?

I'm lost and confused googling. Please provide any links where to start, given that has knowledge on ruby, javascript, basic networking in ruby.

like image 666
pahnin Avatar asked Jun 12 '12 06:06

pahnin


People also ask

How do you know if a WebSocket is closed?

You can check if a WebSocket is disconnected by doing either of the following: Specifying a function to the WebSocket. onclose event handler property, or; Using addEventListener to listen to the close event.

When WebSocket connection is closed?

The WebSocket is closed before the connection is established error message indicates that some client code, or other mechanism, has closed the websocket connection before the connection was fully established.

Which method is used to close the WebSocket?

Which method is used to close the WebSocket? Explanation: The Socket. close() is used to close the WebSocket. The Close method closes the remote host connection and releases all managed and unmanaged resources associated with the Socket.

How do I check my WebSocket connection status?

You can check if a WebSocket is connected by doing either of the following: Specifying a function to the WebSocket. onopen event handler property, or; Using addEventListener to listen to the open event.


1 Answers

i currently using em-websocket

EventMachine.run {

    EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080) do |ws|
        ws.onopen {
          puts "WebSocket connection open"

          # publish message to the client
          ws.send "Hello Client"
        }

        ws.onclose { puts "Connection closed" }
        ws.onmessage { |msg|
          puts "Recieved message: #{msg}"
          ws.send "Pong: #{msg}"
        }
    end
}

for more info see another thread about ruby & websocket:

like image 171
pylover Avatar answered Oct 03 '22 17:10

pylover