sinatra_sockets 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0314afe5db91055d0bab96f4d881a9e666f3988f
4
- data.tar.gz: 293328fae1c693c9375f8c65f2299e4ee2177b0d
3
+ metadata.gz: 85832d4bf9cf5f368b6e6a837e75acfe647c6829
4
+ data.tar.gz: 289bf9344a3e70b8fcaf585570be04df8c8235c2
5
5
  SHA512:
6
- metadata.gz: 649103187d96b308ee18a5c76bf8e96816c98a45c6ebabe723a9064de94f750bf34af77f169379dfefea28098525c919cf19dee2912d8e3f0dea7efa6095ec2d
7
- data.tar.gz: 1c20e7f07a3fb6867c15d419b7a03af1d99890b728dcadbdf62556e700a30455848130814d132a4a813e8bd6e2427353543129bd957013e80f4a5ced6e1e6b4c
6
+ metadata.gz: b44d3168ac29c9c4deed9f404b736abc5cadb4a5086a6eb9ff43071161276a765cef761364c954405da49584b05d62694551f2297ab168f154899868c00a76e1
7
+ data.tar.gz: b35d412caf5189d3dde2afb682e8947b8ec3cca4c23510d6c3be90e7213579d5a7d689fd5cc9a6ed0006fa6854c7a076b62250107b1025e2fa69e06d7953e5f9
@@ -0,0 +1,13 @@
1
+ A simple sinatra websocket server with faye/eventmaching
2
+
3
+ to start: `thin start`
4
+
5
+ to use command line client, open a new terminal and run `ruby client.rb`.
6
+
7
+ To understand what's going on, look at the source code,
8
+ and raise an issue on [the github page](http://github.com/maxpleaner/sinatra_sockets)
9
+ if there's any confusion.
10
+
11
+ **required ruby version** `2.3`
12
+
13
+ **platform** tested only on MRI and unix
@@ -0,0 +1,30 @@
1
+ require 'faye/websocket'
2
+ require 'eventmachine'
3
+ require 'byebug'
4
+ require 'gemmy'
5
+
6
+ Settings = {awaiting_input: false }
7
+ EM.run do
8
+
9
+ EM.tick_loop do
10
+ if !Settings[:awaiting_input]
11
+ Thread.new do
12
+ Settings[:awaiting_input] = true
13
+ inp = gets.chomp
14
+ Settings[:awaiting_input] = false
15
+ Ws.send inp
16
+ end
17
+ sleep 0.2
18
+ end
19
+ end.on_stop { EM.stop }
20
+
21
+ ServerWebsocketUrl = ENV["SERVER_WS_URL"] || 'ws://localhost:3000/'
22
+
23
+ Ws = Faye::WebSocket::Client.new ServerWebsocketUrl
24
+
25
+ Ws.on :message do |event|
26
+ puts event.data
27
+ end
28
+
29
+ end
30
+
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SinatraSockets
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_sockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - maxpleaner
@@ -33,6 +33,8 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - bin/sinatra_sockets
35
35
  - lib/server_skeleton/Gemfile
36
+ - lib/server_skeleton/README.md
37
+ - lib/server_skeleton/client.rb
36
38
  - lib/server_skeleton/config.ru
37
39
  - lib/server_skeleton/lib/routes.rb
38
40
  - lib/server_skeleton/lib/routes/index.rb