stormy-cloud 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/transport.rb +3 -4
  2. data/lib/transports/tcp.rb +7 -1
  3. metadata +1 -1
@@ -1,4 +1,3 @@
1
- require 'base64'
2
1
  require 'digest'
3
2
  require 'msgpack'
4
3
  require 'securerandom'
@@ -148,7 +147,7 @@ class StormyCloudTransport
148
147
  def handle(string)
149
148
  valid_commands = ["HELLO", "GET", "PUT"]
150
149
  command = unserialize(string)
151
-
150
+
152
151
  if not (command.kind_of?(Array) and valid_commands.include? command[0])
153
152
  # The command is invalid.
154
153
  return serialize("INVALID COMMAND")
@@ -214,13 +213,13 @@ class StormyCloudTransport
214
213
  # This can be overridden by the specific transport if the protocol used is
215
214
  # such that this mode of serialization is disadvantageous.
216
215
  def serialize(object)
217
- Base64::encode64(object.to_msgpack)
216
+ Marshal.dump(object)
218
217
  end
219
218
 
220
219
  # Unserialize an object which has been serialized using the `serialize`
221
220
  # method.
222
221
  def unserialize(string)
223
- MessagePack.unpack(Base64::decode64(string))
222
+ Marshal.load(string)
224
223
  end
225
224
 
226
225
  # Return all variables relevant to the job status.
@@ -7,7 +7,12 @@ class StormyCloudTCPTransport < StormyCloudTransport
7
7
  @server_thread = Thread.new do
8
8
  loop do
9
9
  Thread.start(@server.accept) do |client|
10
- client.puts handle(client.gets)
10
+ message = ''
11
+ while (t = client.gets).strip != "ENDOFTHEMESSAGE"
12
+ message += t
13
+ end
14
+ reply = handle(message)
15
+ client.puts reply
11
16
  end
12
17
  end
13
18
  end
@@ -21,6 +26,7 @@ class StormyCloudTCPTransport < StormyCloudTransport
21
26
  begin
22
27
  s = TCPSocket.new(@stormy_cloud.server, @stormy_cloud.config(:port))
23
28
  s.puts string
29
+ s.puts "ENDOFTHEMESSAGE"
24
30
  res = s.gets
25
31
  s.close
26
32
  res
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stormy-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: