krpc 0.1.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0f3c082901ab9699ece2d8033381250ec2990a7
4
- data.tar.gz: 00a0e3ac5f6e4b7e4c105557f8ee68f62a143a6a
3
+ metadata.gz: 977be90d9516ca166de911cebca7bcac80bd174b
4
+ data.tar.gz: 29ed63e761d2198d580abb49f2f2a3c43b56ee31
5
5
  SHA512:
6
- metadata.gz: 737ad5c400faf806f6211f5c4928d39126f2738bc401fe09926885444a4857000cd454bf5711904f3ba0a6778df0229928263c2852ac69016d7e53190b31eb24
7
- data.tar.gz: 4c9a51a7828b56e27ca6be04f2ab9fcc53d7d0cabd042710e20af05ec36fea994b41878f6b8024a72199d9021eb405e9be7f418b10ff7db7e9e675177fb7a5b0
6
+ metadata.gz: c07dd473607aaa175c3167f8f1c68ec03473ad839e43fe70f772e63a11b05633485c9b1f1810df73b7132bf043e3fd6c76823dd8393f8ba5dba8da3cd42a56d1
7
+ data.tar.gz: 29709a970d7d2c80517d8e22174732325095d24acc0fc1ff8114dc37a1feba558db5e82af8b7e4e4866872fd629761c3e5610a81c63c570ee962650100953bc8
@@ -1,8 +1,23 @@
1
1
 
2
+ v0.2.0 (26 Sep 2015)
3
+ ========
4
+ + **Added Streaming support**:
5
+ + Stream creation by calling method with `_stream` suffix
6
+ + **Improved in-REPL experience**:
7
+ + Added documentation content received from kRPC server to in-REPL documentation output
8
+ + Improved `to_s` and `inspect` methods in `KRPC::Gen::ClassBase` and `KRPC::Streaming::Stream` classes
9
+ + Arguments of `KRPC::Client#initialize` method turned into keyword arguments
10
+ + RPC methods are no longer bound to single `KRPC::Client` object (Fix #3)
11
+ + Fixed arguments sometimes not correctly passed to RPC methods (due to Ruby 2.2.1 bug) (Fix #1)
12
+ + Removed `required_params_count` parameter from `Client#build_request` method, and made that method public
13
+ + `KRPC::TypeStore`'s methods changed, to be class level methods
14
+ + Added dependency on *Nokogiri* and development dependency on *Pry* and *hanna-nouveau*
15
+ + Minor improvements and fixes
16
+
2
17
  v0.1.1 (9 Sep 2015)
3
18
  ========
4
- + Added KRPC.connect method
5
- + Added block argument to Client#connect and Client#connect! methods
19
+ + Added `KRPC.connect` method
20
+ + Added block argument to `Client#connect` and `Client#connect!` methods
6
21
 
7
22
  v0.1.0 (6 Sep 2015)
8
23
  ========
data/README.md CHANGED
@@ -13,7 +13,7 @@ Basic usage
13
13
 
14
14
  ```ruby
15
15
  require 'krpc'
16
- client = KRPC.connect("client name here")
16
+ client = KRPC.connect(name: "client name here")
17
17
  vessel = client.space_center.active_vessel
18
18
  ctrl = vessel.control
19
19
  ctrl.sas = true
@@ -28,14 +28,12 @@ Most of the API is *very* similar to what can be found in (official) Python clie
28
28
  So official documentation at http://djungelorm.github.io/krpc/docs/ is definitely a good read.
29
29
  The rest of this file describes few differences there are between Ruby and Python client libraries.
30
30
 
31
- **NOTE:** Streaming is not supported in the current version of kRPC-rb.
32
-
33
31
  Connecting and disconnecting
34
32
  -------
35
33
  When you are in REPL, you can connect to kRPC server in this way:
36
34
 
37
35
  ```ruby
38
- client = KRPC.connect({name for client}, {host}, {rpc_port}, {stream_port})
36
+ client = KRPC.connect(name: {name for the client}, host: {kRPC server host}, rpc_port: {kRPC server rpc port}, stream_port: {kRPC server stream port})
39
37
  # use client here...
40
38
  client.close
41
39
  ```
@@ -44,7 +42,7 @@ All of the `KRPC.connect`'s arguments are optional, so `client = KRPC.connect` m
44
42
  Alternatively you can be more explicit (yet still obtain the same result):
45
43
 
46
44
  ```ruby
47
- client = KRPC::Client.new({name for client}, {host}, {rpc_port}, {stream_port}).connect!
45
+ client = KRPC::Client.new( {The same argument list as KRPC.connect has} ).connect!
48
46
  # use client here...
49
47
  client.close
50
48
  ```
@@ -87,12 +85,14 @@ The best way to explore the API is to run REPL and try what each method does for
87
85
  I highly recommend using [Pry](https://github.com/pry/pry) as REPL. This way you can `ls` any object you receive and see what methods you can call on it. When you want to know more about specific method, then just stuck `_doc` at the end of it's name and press enter:
88
86
 
89
87
  ```ruby
90
- [29] pry(main)> cl.space_center.transform_position_doc
88
+ [29] pry(main)> client.space_center.transform_position_doc
91
89
  SpaceCenter.transform_position(
92
- position :Array[Float, Float, Float],
93
- from :ReferenceFrame,
94
- to :ReferenceFrame
95
- ) :Array[Float, Float, Float]
90
+ position :Array[Float, Float, Float], - Position vector in reference frame from.
91
+ from :ReferenceFrame, - The reference frame that the position vector is in.
92
+ to :ReferenceFrame - The reference frame to covert the position vector to.
93
+ ) :Array[Float, Float, Float] - The corresponding position vector in reference frame to.
94
+
95
+ Converts a position vector from one reference frame to another.
96
96
  => nil
97
97
  ```
98
98
 
@@ -104,22 +104,48 @@ Combination of `ls`s and `_doc`s should teach you API in no time (also don't be
104
104
  ```ruby
105
105
  [31] pry(main)> sc = client.space_center;
106
106
  [32] pry(main)> ls sc
107
- KRPC::Doc::SuffixMethods#methods: method_missing
108
- KRPC::Services::ServiceBase#methods: client
107
+ ...
109
108
  KRPC::Services::SpaceCenter::AvailableToClassAndInstance#methods:
110
109
  can_rails_warp_at clear_target draw_line launch_vessel_from_vab transform_position transform_velocity
111
- clear_drawing draw_direction launch_vessel_from_sph transform_direction transform_rotation warp_to
110
+ clear_drawing draw_direction launch_vessel_from_sph transform_direction transform_rotation warp_to
112
111
  KRPC::Services::SpaceCenter#methods:
113
112
  active_vessel far_available physics_warp_factor rails_warp_factor= target_body= target_vessel vessels warp_rate
114
113
  active_vessel= g physics_warp_factor= remote_tech_available target_docking_port target_vessel= warp_factor
115
- bodies maximum_rails_warp_factor rails_warp_factor target_body target_docking_port= ut warp_mode
116
- instance variables: @client
114
+ bodies maximum_rails_warp_factor rails_warp_factor target_body target_docking_port= ut warp_mode
115
+ ...
117
116
  [33] pry(main)> sc.warp_to_doc;
118
117
  SpaceCenter.warp_to(
119
- ut :Float,
120
- max_rails_rate :Float = 100000.0,
121
- max_physics_rate :Float = 2.0
122
- ) :nil
118
+ ut :Float, - The universal time to warp to, in seconds.
119
+ max_rails_rate :Float = 100000.0, - The maximum warp rate in regular "on-rails" time warp.
120
+ max_physics_rate :Float = 2.0 - The maximum warp rate in physical time warp.
121
+ ) :nil - When the time warp is complete.
122
+
123
+ Uses time acceleration to warp forward to a time in the future, specified by universal time ut. This call blocks until the desired time is reached. Uses regular "on-rails" or physical time warp as appropriate. For example, physical time warp is used when the active vessel is traveling through an atmosphere. When using regular "on-rails" time warp, the warp rate is limited by max_rails_rate, and when using physical time warp, the warp rate is limited by max_physics_rate.
124
+ ```
125
+
126
+ Streaming
127
+ -------
128
+ A stream repeatedly executes a function on the server, with a fixed set of argument values. It provides a more efficient way of repeatedly getting the result of calling function on the server, without having to invoke it directly – which incurs communication overheads.
129
+
130
+ To create a stream, call a method with `_stream` suffix. This will return `KRPC::Streaming::Stream` instance. You can call `get` (or `value`) on the `Stream` instance to get the recent value received by this stream. To deactivate the stream call `remove` (or `close`) on the `Stream` instance.
131
+
132
+ Example without streaming:
133
+ ```ruby
134
+ vessel = client.space_center.active_vessel
135
+ refframe = vessel.orbit.body.reference_frame
136
+ loop do
137
+ puts vessel.position(refframe)
138
+ end
139
+ ```
140
+ Equivalent example with streaming:
141
+ ```ruby
142
+ vessel = client.space_center.active_vessel
143
+ refframe = vessel.orbit.body.reference_frame
144
+ pos_stream = vessel.position_stream(refframe)
145
+ loop do
146
+ puts pos_stream.get
147
+ end
148
+ pos_stream.remove #note: dead code - just as an example
123
149
  ```
124
150
 
125
151
  Want to know more?
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "krpc"
8
- s.version = "0.1.1.1"
8
+ s.version = "0.2.0"
9
9
  s.authors = ["Tomasz Więch"]
10
10
  s.email = ["tewu.dev@gmail.com"]
11
11
 
@@ -19,12 +19,15 @@ Gem::Specification.new do |s|
19
19
  s.extra_rdoc_files = ["README.md"]
20
20
  s.rdoc_options << "--markup" << "markdown" <<
21
21
  "--format" << "hanna" <<
22
+ "--title" << "kRPC-rb API Docs" <<
22
23
  "--main" << "README.md"
23
24
 
24
25
  s.required_ruby_version = '>= 2.1.0'
25
26
 
26
27
  s.add_runtime_dependency "ruby_protobuf", "~> 0.4"
27
28
  s.add_runtime_dependency "colorize", "~> 0.7"
29
+ s.add_runtime_dependency "nokogiri", "~> 1.6"
28
30
  s.add_development_dependency "bundler", "~> 1.10"
31
+ s.add_development_dependency "pry", "~> 0.10"
32
+ s.add_development_dependency "hanna-nouveau", "~> 0.4"
29
33
  end
30
-
@@ -6,14 +6,9 @@ module KRPC
6
6
  # Connect to a kRPC server, generate services API and return Client object. If the block is
7
7
  # given, then it's called passing Client object and the connection to kRPC server is closed
8
8
  # at the end of the block.
9
- def connect(name = Client::DEFAULT_NAME, host = Connection::DEFAULT_SERVER_HOST, rpc_port = Connection::DEFAULT_SERVER_RPC_PORT, stream_port = Connection::DEFAULT_SERVER_STREAM_PORT, &block)
10
- client = Client.new(name, host, rpc_port, stream_port).connect!
11
- if block_given?
12
- begin block.call(client) ensure client.close end
13
- end
14
- client
9
+ def connect(*args, &block)
10
+ Client.new(*args).connect!(&block)
15
11
  end
16
12
 
17
13
  end
18
14
  end
19
-
@@ -122,4 +122,3 @@ module KRPC
122
122
  end
123
123
  end
124
124
  end
125
-
@@ -78,4 +78,3 @@ module KRPC
78
78
  end
79
79
  end
80
80
  end
81
-
@@ -3,6 +3,7 @@ require 'krpc/service'
3
3
  require 'krpc/types'
4
4
  require 'krpc/encoder'
5
5
  require 'krpc/decoder'
6
+ require 'krpc/streaming'
6
7
  require 'krpc/error'
7
8
  require 'krpc/core_extensions'
8
9
  require 'krpc/KRPC.pb'
@@ -18,7 +19,7 @@ module KRPC
18
19
  # `client.service_name.procedure_name(parameter, ...)`
19
20
  #
20
21
  # ### Example:
21
- # client = KRPC::Client.new("my client").connect!
22
+ # client = KRPC::Client.new(name: "my client").connect!
22
23
  # ctrl = client.space_center.active_vessel.control
23
24
  # ctrl.activate_next_stage
24
25
  # ctrl.throttle = 1 # Full ahead!
@@ -31,17 +32,18 @@ module KRPC
31
32
 
32
33
  include Doc::SuffixMethods
33
34
 
34
- attr_reader :name, :rpc_connection, :stream_connection, :type_store, :krpc
35
-
35
+ attr_reader :name, :rpc_connection, :stream_connection, :streams_manager, :krpc
36
+
36
37
  # Create new Client object, optionally specifying IP address and port numbers on witch kRPC
37
38
  # server is listening and the name for this client (up to 32 bytes of UTF-8 encoded text).
38
- def initialize(name = DEFAULT_NAME, host = Connection::DEFAULT_SERVER_HOST, rpc_port = Connection::DEFAULT_SERVER_RPC_PORT, stream_port = Connection::DEFAULT_SERVER_STREAM_PORT)
39
+ def initialize(name: DEFAULT_NAME, host: Connection::DEFAULT_SERVER_HOST, rpc_port: Connection::DEFAULT_SERVER_RPC_PORT, stream_port: Connection::DEFAULT_SERVER_STREAM_PORT)
39
40
  @name = name
40
- @rpc_connection = RPCConncetion.new(name, host, rpc_port)
41
- @stream_connection = StreamConncetion.new(rpc_connection, host, stream_port)
42
- @type_store = Types::TypeStore.new
41
+ @rpc_connection = RPCConnection.new(name, host, rpc_port)
42
+ @stream_connection = StreamConnection.new(rpc_connection, host, stream_port)
43
+ @streams_manager = Streaming::StreamsManager.new(self)
44
+ @services = {}
43
45
  @krpc = Services::KRPC.new(self)
44
- Doc.add_docstring_info(false, self.class, "krpc", return_type: @krpc.class)
46
+ Doc.add_docstring_info(false, self.class, "krpc", return_type: @krpc.class, xmldoc: "<doc><summary>Core kRPC service, e.g. for querying for the available services. Most of this functionality is used internally by the Ruby client and therefore does not need to be used directly from application code.</summary></doc>")
45
47
  end
46
48
 
47
49
  # Connect to a kRPC server on the IP address and port numbers specified during this client
@@ -51,6 +53,7 @@ module KRPC
51
53
  def connect(&block)
52
54
  rpc_connection.connect
53
55
  stream_connection.connect
56
+ streams_manager.start_streaming_thread
54
57
  call_block_and_close(block) if block_given?
55
58
  self
56
59
  end
@@ -68,6 +71,8 @@ module KRPC
68
71
  # Close connection to kRPC server. Returns `true` if the connection has closed or `false` if
69
72
  # the client had been already disconnected.
70
73
  def close
74
+ streams_manager.remove_all_streams
75
+ streams_manager.stop_streaming_thread
71
76
  stream_connection.close
72
77
  rpc_connection.close
73
78
  end
@@ -93,7 +98,7 @@ module KRPC
93
98
  # To regenerate API create new Client object and call #generate_services_api! on it.
94
99
  #
95
100
  # ### Example
96
- # client = KRPC::Client.new("my client").connect # Notice that it is #connect being called, not #connect!
101
+ # client = KRPC::Client.new(name: "my client").connect # Notice that it is 'Client#connect' being called, not 'Client#connect!'
97
102
  # sc = client.space_center # => Exception (undefined method "space_center")
98
103
  # client.generate_services_api!
99
104
  # sc = client.space_center # => KRPC::Services::SpaceCenter object
@@ -107,12 +112,14 @@ module KRPC
107
112
  resp = krpc.get_services
108
113
  resp.services.each do |service_msg|
109
114
  next if service_msg.name == "KRPC"
110
- service = Services.create_service(service_msg, self)
111
- method_name = service.class.class_name.underscore
115
+ service_class = Services.create_service(service_msg)
116
+ method_name = service_class.class_name.underscore
112
117
  self.class.instance_eval do
113
- define_method method_name do service end
118
+ define_method method_name do
119
+ @services[service_class.class_name] ||= service_class.new(self)
120
+ end
114
121
  end
115
- Doc.add_docstring_info(false, self.class, method_name, return_type: service.class)
122
+ Doc.add_docstring_info(false, self.class, method_name, return_type: service_class, xmldoc: service_msg.documentation)
116
123
  end
117
124
  self
118
125
  end
@@ -123,9 +130,9 @@ module KRPC
123
130
  end
124
131
 
125
132
  # Execute an RPC.
126
- def rpc(service, procedure, args=[], kwargs={}, param_names=[], param_types=[], required_params_count=0, param_default=[], return_type: nil)
133
+ def rpc(service, procedure, args=[], kwargs={}, param_names=[], param_types=[], param_default=[], return_type: nil)
127
134
  # Send request
128
- req = build_request(service, procedure, args, kwargs, param_names, param_types, required_params_count, param_default)
135
+ req = build_request(service, procedure, args, kwargs, param_names, param_types, param_default)
129
136
  rpc_connection.send Encoder.encode_request(req)
130
137
  # Receive response
131
138
  resp_length = rpc_connection.recv_varint
@@ -138,23 +145,19 @@ module KRPC
138
145
  if return_type == nil
139
146
  nil
140
147
  else
141
- Decoder.decode(resp.return_value, return_type, type_store)
148
+ Decoder.decode(resp.return_value, return_type, self)
142
149
  end
143
150
  rescue IOError => e
144
151
  raise(Exception, "RPC call attempt while not connected to server -- call Client#connect first") if not connected?
145
152
  raise e
146
153
  end
147
154
 
148
- protected #----------------------------------
149
-
150
- def call_block_and_close(block)
151
- begin block.call(self) ensure close end
152
- end
153
-
154
155
  # Build a PB::Request object.
155
- def build_request(service, procedure, args=[], kwargs={}, param_names=[], param_types=[], required_params_count=0, param_default=[])
156
+ def build_request(service, procedure, args=[], kwargs={}, param_names=[], param_types=[], param_default=[])
156
157
  begin
157
- raise(ArgumentError, "param_names and param_types should be equal length\n\tparam_names = #{param_names}\n\tparam_types = #{param_types}") unless param_names.size == param_types.size
158
+ raise(ArgumentError, "param_names and param_types should be equal length\n\tparam_names = #{param_names}\n\tparam_types = #{param_types}") unless param_names.length == param_types.length
159
+ raise(ArgumentError, "param_names and param_default should be equal length\n\tparam_names = #{param_names}\n\tparam_default = #{param_default}") unless param_names.length == param_default.length
160
+ required_params_count = param_default.take_while(&:nil?).count
158
161
  raise ArgumentsNumberErrorSig.new(args.count, required_params_count..param_names.count) unless args.count <= param_names.count
159
162
  kwargs_remaining = kwargs.count
160
163
 
@@ -172,21 +175,26 @@ module KRPC
172
175
  else raise ArgumentErrorSig.new("missing argument for parameter \"#{name}\"")
173
176
  end
174
177
  begin
175
- arg = type_store.coerce_to(arg, param_types[i])
178
+ arg = TypeStore.coerce_to(arg, param_types[i])
176
179
  rescue ValueError
177
180
  raise ArgumentErrorSig.new("argument for parameter \"#{name}\" must be a #{param_types[i].ruby_type} -- got #{args[i]} of type #{args[i].class}")
178
181
  end
179
- v = Encoder.encode(arg, param_types[i], type_store)
182
+ v = Encoder.encode(arg, param_types[i])
180
183
  PB::Argument.new(position: i, value: v)
181
184
  end
182
185
  end.compact
183
186
  raise ArgumentErrorSig.new("keyword arguments for non existing parameters: #{(kwargs.keys - param_names_symbols).join(", ")}") unless kwargs_remaining == 0
184
187
  rescue ArgumentErrorSig => err
185
- raise err.with_signature(Doc.docstring_for_procedure(service, procedure))
188
+ raise err.with_signature(Doc.docstring_for_procedure(service, procedure, false))
186
189
  end
187
190
  PB::Request.new(service: service, procedure: procedure, arguments: req_args)
188
191
  end
189
192
 
193
+ protected #----------------------------------
194
+
195
+ def call_block_and_close(block)
196
+ begin block.call(self) ensure close end
197
+ end
198
+
190
199
  end
191
200
  end
192
-
@@ -49,10 +49,9 @@ module KRPC
49
49
  def handshake; end
50
50
  def cleanup; end
51
51
 
52
- def send(msg) @socket.send(msg,0) end
52
+ def send(msg) @socket.send(msg, 0) end
53
53
  def recv(maxlen = 1) @socket.recv(maxlen) end
54
54
 
55
-
56
55
  def recv_varint
57
56
  int_val = 0
58
57
  shift = 0
@@ -62,21 +61,20 @@ module KRPC
62
61
  return int_val if (byte & 0b1000_0000) == 0
63
62
  shift += 7
64
63
  raise(RuntimeError, "too many bytes when decoding varint") if shift >= 64
65
- sleep 0.1
66
64
  end
67
65
  end
68
66
 
69
67
  protected #----------------------------------
70
68
 
71
69
  def trim_fill(str, len, fill_char = "\x00")
72
- str = str.encode("UTF-8")[0,len]
70
+ str = str.encode("UTF-8")[0, len]
73
71
  str + fill_char*(len-str.length)
74
72
  end
75
73
  end
76
74
 
77
75
  ##
78
76
  # TCP connection for sending RPC calls and retrieving it's results.
79
- class RPCConncetion < Connection
77
+ class RPCConnection < Connection
80
78
  attr_reader :name, :client_id
81
79
 
82
80
  def initialize(name, host = DEFAULT_SERVER_HOST, port = DEFAULT_SERVER_RPC_PORT)
@@ -99,7 +97,7 @@ module KRPC
99
97
 
100
98
  ##
101
99
  # TCP connection for streaming.
102
- class StreamConncetion < Connection
100
+ class StreamConnection < Connection
103
101
  attr_reader :rpc_connection
104
102
 
105
103
  def initialize(rpc_connection, host = DEFAULT_SERVER_HOST, port = DEFAULT_SERVER_STREAM_PORT)
@@ -118,4 +116,3 @@ module KRPC
118
116
  end
119
117
 
120
118
  end
121
-
@@ -26,3 +26,8 @@ class String
26
26
  end
27
27
  end
28
28
 
29
+ class Array
30
+ def extract_kwargs!
31
+ last.is_a?(::Hash) ? pop : {}
32
+ end
33
+ end
@@ -10,30 +10,30 @@ module KRPC
10
10
  class << self
11
11
 
12
12
  # Given a type object, and serialized data, decode the ruby value/object
13
- def decode(data, type, type_store)
13
+ def decode(data, type, client)
14
14
  if type.is_a?(Types::MessageType) then decode_message(data, type)
15
15
  elsif type.is_a?(Types::ValueType) then decode_value(data, type)
16
16
  elsif type.is_a?(Types::EnumType)
17
- v = decode_value(data, type_store.as_type("int32"))
17
+ v = decode_value(data, TypeStore["int32"])
18
18
  type.ruby_type.key(v)
19
19
  elsif type.is_a?(Types::ClassType)
20
- remote_oid = decode_value(data, type_store.as_type("uint64"))
20
+ remote_oid = decode_value(data, TypeStore["uint64"])
21
21
  if remote_oid != 0
22
- type.ruby_type.new(remote_oid)
22
+ type.ruby_type.new(client, remote_oid)
23
23
  else nil end
24
24
  elsif type.is_a?(Types::ListType)
25
- msg = decode_message(data, type_store.as_type("KRPC.List"))
26
- msg.items.map{|x| decode(x, type.value_type, type_store)}.to_a
25
+ msg = decode_message(data, TypeStore["KRPC.List"])
26
+ msg.items.map{|x| decode(x, type.value_type, client)}.to_a
27
27
  elsif type.is_a?(Types::DictionaryType)
28
- msg = decode_message(data, type_store.as_type("KRPC.Dictionary"))
29
- msg.entries.map{|e| [decode(e.key, type.key_type, type_store),
30
- decode(e.value, type.value_type, type_store)]}.to_h
28
+ msg = decode_message(data, TypeStore["KRPC.Dictionary"])
29
+ msg.entries.map{|e| [decode(e.key, type.key_type, client),
30
+ decode(e.value, type.value_type, client)]}.to_h
31
31
  elsif type.is_a?(Types::SetType)
32
- msg = decode_message(data, type_store.as_type("KRPC.Set"))
33
- Set.new(msg.items.map{|x| decode(x, type.value_type, type_store)}.to_a)
32
+ msg = decode_message(data, TypeStore["KRPC.Set"])
33
+ Set.new(msg.items.map{|x| decode(x, type.value_type, client)}.to_a)
34
34
  elsif type.is_a?(Types::TupleType)
35
- msg = decode_message(data, type_store.as_type("KRPC.Tuple"))
36
- msg.items.zip(type.value_types).map{|x,t| decode(x, t, type_store)}.to_a
35
+ msg = decode_message(data, TypeStore["KRPC.Tuple"])
36
+ msg.items.zip(type.value_types).map{|x,t| decode(x, t, client)}.to_a
37
37
  else raise RuntimeError.new("Cannot decode type #{type} from data: #{data}")
38
38
  end
39
39
  end
@@ -51,4 +51,3 @@ module KRPC
51
51
  end
52
52
  end
53
53
  end
54
-