Code Monkey home page Code Monkey logo

websocket-client-simple's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

websocket-client-simple's Issues

How to access the callback's initial environment?

Blocks that were provided to the EventEmmiter as callbacks are evaluated inside the Client class. It's easy to check:

ws.on :open do
  puts self
end

Will output:

#<WebSocket::Client::Simple::Client:0x007f890bc50698>

So code like follows wont work:

state = :initial

ws.on :open do
  state = :connected
end

What's the convenient way to access the initial environment where the block was created?

heartbeat packet

定期的に空パケットを送って接続が生きているか確認するべき

self is dropped in the callbacks

It is actually a bug in the eventemitter gem, and serious one. Event callbacks for the socket are called on the wrong context, set by the emitter. It took me several hours to trace. I suggest to fix emitter or refrain of using it.

Sample:
`
me = self
@ws = WebSocket::Client::Simple.connect(ws_url)

@ws.on(:open) {
if me != self
puts "\n\n\nSelf is set to wrong in the callback in #{RUBY_VERSION}\n\n\n"
end
}
`

Silent errors

I have a syntax error.

When the syntax error is inside of on :event block, it is silenced.

client should not override #send

The client defines a #send method that overrides the default Object#send method of a plain Ruby Object. This can cause problems when trying to use SimpleDelegator to wrap the client class, as the Object#send method is called on the SimpleDelegator wrapper object instead of it being delegated to the client object.

"type" argument in Client#send

ws = WebSocket::Client::Simple.connect url

ws.on :open do
  ws.send("foo")  ## default :type => :text
  ws.send(bynary_data, :type => :binary)
end

ws.on :open not always triggers

I have Java websocket server running on which I am trying to connect using websocket-client-simple client.
Some times on :open is not triggered, even not and exception in on :error or in rescue block.

Keeps closing connection

I have nodejs socket server that I connect to.
The ruby client constantly closes the connection after a minute or so and it does not reconnect automatically.

Am I supposed to send some kind of ping to keep the connection alive?

race condition can cause missed events

Because the Client currently spawns the socket reading thread in the object initializer, there's a small window where the user of this library hasn't had a chance to set up their event handlers yet, but the connection can emit events. For illustration:

ws = WebSocket::Client::Simple.connect 'ws://example.com:8888'

# a :message or :open event could be emitted in this window of time, before we
# have a chance to register the handler below, and it will be lost permanently

ws.on :open do |msg|
  puts msg.data
end

Possible solutions include:

# the connection thread is not actually started until this method is called, after we
# have a chance to register our handlers
ws.start

or:

ws = WebSocket::Client::Simple.connect('ws://example.com:8888') do |ws|
  # we have a chance to register our handlers during the constructor,
  # before the thread is started
  ws.on :open do |msg|
    puts msg.data
  end
end

CLOSE frame

切断時にcloseフレーム送ってない気がするので調べる

Can work with Ruby 1.9.3?

Hi,

I have an old repo which uses Ruby 1.9.3 and does web socket client connections. Is it possible to use this gem with Ruby 1.9.3?

Currently I am getting error while installing:

E:\Jmyapp>gem install websocket-client-simple
ERROR:  Error installing websocket-client-simple:
        websocket requires Ruby version >= 2.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.