distributor 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,8 +7,8 @@ class Distributor::Multiplexer
7
7
 
8
8
  def initialize(output)
9
9
  @output = output
10
- @readers = {}
11
- @writers = {}
10
+ @readers = Hash.new { |hash,key| hash[key] = StringIO.new }
11
+ @writers = Hash.new { |hash,key| hash[key] = StringIO.new }
12
12
  @write_lock = Mutex.new
13
13
 
14
14
  @output.sync = true
@@ -22,11 +22,11 @@ class Distributor::Multiplexer
22
22
  end
23
23
 
24
24
  def reader(ch)
25
- @readers[ch] || raise("no such channel: #{ch}")
25
+ @readers[ch]
26
26
  end
27
27
 
28
28
  def writer(ch)
29
- @writers[ch] || raise("no such channel: #{ch}")
29
+ @writers[ch]
30
30
  end
31
31
 
32
32
  def input(io)
@@ -101,6 +101,10 @@ class Distributor::Server
101
101
  data["id"]
102
102
  end
103
103
 
104
+ def output(ch, data={})
105
+ @multiplexer.output ch, Distributor::OkJson.encode(data)
106
+ end
107
+
104
108
  def on_command(&blk)
105
109
  @on_command = blk
106
110
  end
@@ -1,5 +1,5 @@
1
1
  module Distributor
2
2
 
3
- VERSION = "0.4.4"
3
+ VERSION = "0.5.0"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: distributor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70128704949500 !ruby/object:Gem::Requirement
16
+ requirement: &70092817757520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.13.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70128704949500
24
+ version_requirements: *70092817757520
25
25
  description: TCP Multiplexer
26
26
  email: ddollar@gmail.com
27
27
  executables: []