farcall 0.3.3 → 0.3.4

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: c4d68141e1f69c5dc1e4e367ef061e3469cc9b88
4
- data.tar.gz: 699df7d0a42dfd4d4f1c982d9fa6091c2fe7372a
3
+ metadata.gz: e62f0ec5501d7053137341f5ec5f46100b692b61
4
+ data.tar.gz: 9549befd37e328bef65639d99953ee15bae8da2c
5
5
  SHA512:
6
- metadata.gz: 9a639e7585e6b18c123b41b780d99015c2fbab18e9076b3a9b1e735dc50223dd2ad9c55b796cdd80b16179de1ec69360c6dc10ab09a07b0fb46a897442eeec83
7
- data.tar.gz: d813cc94cc211544084de25c8aaa1b30cfa29f00851ab1437be7ea0c57e38d4574319dc1265d109061fb0e086171dc409145656b346611001c2c1545ad51a563
6
+ metadata.gz: 37f168b9631e06851ca3ebb9f84b19dd145836878210a3d7050b343b43f6e57c9bf7790f1969e9fb951270e941a7a10b14bb0f9b537ed6c2e6d805989ce2f974
7
+ data.tar.gz: 103a6f0f987801726f1876bf6f696926aada0644ed815d6ec50a06d04ced6c483f972d4011494957daec606aadc7b34e0a00793aa3e74123248bb7529b470f07
@@ -1,3 +1,3 @@
1
1
  module Farcall
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
@@ -1,55 +1,59 @@
1
1
  require 'farcall'
2
- require 'websocket-client-simple'
3
- require_relative './monitor_lock'
4
- require 'json'
2
+ begin
3
+ require 'websocket-client-simple'
4
+ require_relative './monitor_lock'
5
+ require 'json'
5
6
 
6
- module Farcall
7
- # Websocket client transport using JSON encodeing. Works with ruby threads, pure ruby, runs
8
- # everywhere. Use if like any thoer Farcall::Transport, for example:
9
- #
10
- # in your Gemfile
11
- #
12
- # gem 'websocket-client-simple'
13
- #
14
- # in the code
15
- #
16
- # wst = Farcall::WebsocketJsonClientTransport.new 'ws://icodici.com:8080/test'
17
- # i = Farcall::Interface.new transport: wst
18
- # result = i.authenticate(login, password) # remote call via interface...
19
- #
20
- class WebsocketJsonClientTransport < Farcall::Transport
7
+ module Farcall
8
+ # Websocket client transport using JSON encodeing. Works with ruby threads, pure ruby, runs
9
+ # everywhere. Use if like any thoer Farcall::Transport, for example:
10
+ #
11
+ # in your Gemfile
12
+ #
13
+ # gem 'websocket-client-simple'
14
+ #
15
+ # in the code
16
+ #
17
+ # wst = Farcall::WebsocketJsonClientTransport.new 'ws://icodici.com:8080/test'
18
+ # i = Farcall::Interface.new transport: wst
19
+ # result = i.authenticate(login, password) # remote call via interface...
20
+ #
21
+ class WebsocketJsonClientTransport < Farcall::Transport
21
22
 
22
- # Create transport connected to the specified websocket url. Constructor blocks
23
- # until connected, or raise error if connection can't be established. Transport uses
24
- # JSON encodgin over standard websocket protocol.
25
- def initialize ws_url
26
- # The stranges bug around in the WebSocket::Client (actually in his eventemitter)
27
- me = self
23
+ # Create transport connected to the specified websocket url. Constructor blocks
24
+ # until connected, or raise error if connection can't be established. Transport uses
25
+ # JSON encodgin over standard websocket protocol.
26
+ def initialize ws_url
27
+ # The stranges bug around in the WebSocket::Client (actually in his eventemitter)
28
+ me = self
28
29
 
29
- is_open = Semaphore.new
30
- @ws = WebSocket::Client::Simple.connect(ws_url)
30
+ is_open = Semaphore.new
31
+ @ws = WebSocket::Client::Simple.connect(ws_url)
31
32
 
32
- @ws.on(:open) {
33
- # if me != self
34
- # puts "\n\n\nSelf is set to wrong in the callback in #{RUBY_VERSION}\n\n\n"
35
- # end
36
- # puts "client is open"
37
- is_open.set
38
- }
33
+ @ws.on(:open) {
34
+ # if me != self
35
+ # puts "\n\n\nSelf is set to wrong in the callback in #{RUBY_VERSION}\n\n\n"
36
+ # end
37
+ # puts "client is open"
38
+ is_open.set
39
+ }
39
40
 
40
- @ws.on(:message) { |m|
41
- # puts "ws client received #{JSON.parse m.data}"
42
- me.on_data_received and me.on_data_received.call(JSON.parse m.data)
43
- # puts "and sent"
44
- }
45
- @ws.on(:close) { close }
46
- is_open.wait_set
47
- end
41
+ @ws.on(:message) { |m|
42
+ # puts "ws client received #{JSON.parse m.data}"
43
+ me.on_data_received and me.on_data_received.call(JSON.parse m.data)
44
+ # puts "and sent"
45
+ }
46
+ @ws.on(:close) { close }
47
+ is_open.wait_set
48
+ end
48
49
 
49
- # :nodoc:
50
- def send_data data
51
- @ws.send JSON[data]
52
- end
50
+ # :nodoc:
51
+ def send_data data
52
+ @ws.send JSON[data]
53
+ end
53
54
 
55
+ end
54
56
  end
57
+ rescue LoadError
58
+ $!.to_s =~ /websocket/ or raise
55
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: farcall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - sergeych
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-23 00:00:00.000000000 Z
11
+ date: 2016-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie