Project

weso

0.0
No commit activity in last 3 years
No release in over 3 years
Ruby Websocket Client with the idea of simplicity and efficiency.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1.4
~> 12.0
~> 3.0
~> 1.9.0

Runtime

~> 2.1.2
~> 0.10.0
~> 1.2.8
 Project Readme

weso

Ruby WEbSOcket Client.

Installation

Add this line to your application's Gemfile:

gem 'weso'

And then execute:

bundle install

Or install it yourself as:

gem install weso

Usage

You can create an instance of the Weso::Base::Client class and configure required events with a public connect method on the Weso::Base module. Note, that this method creates a new instance every time. The functionality with valid client reconnection now in progress.

client = Weso::Base.connect 'wss://test.com' do |c|
  c.on :open do
    puts("I've opened a new websocket connection!")
  end
  
  c.on :close do
    puts("I'll miss you! Connection is closed now.")
  end
  
  c.on :error do |error|
    puts("I'm sorry, but something went wrong. Lets check the error:")
    puts(error)
  end
end

If you need to configure encryption settings other than defaults, I advise you to review Weso::Base::SocketCreator class. In order to perform useful work with the client, you need to configure the :message event and not be shy to write first with send_data method:

client.on :message do |message|
  puts(message.data)
end

client.send_data("Hello! How you doing?")

In case if you want to check the client connection status - open?, closed? and handshaked? are your best friends. And do not forget to close the connection when you finished your work:

client.close

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/overchind/weso. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the weso project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.