tribe_em 0.2.0 → 0.3.0

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: 2bb14062ad1aeae1bb01f52c1adb660583a6f749
4
- data.tar.gz: e77ccd1637957d1caca366bc91812f5d452b36a4
3
+ metadata.gz: 7c06effb38bcd4e0a392204e44b7cadf03c9b29b
4
+ data.tar.gz: 7ed3c4e2c315c9d9a1fe788544c5e6cb443f9b33
5
5
  SHA512:
6
- metadata.gz: 46641f248653a157addae472e77d81685f2bd007e5fee88ce8820b048c442b2ca16c1ee19d2af82d225627007e14afc8ca32f422540859f0f0fd2e82b1a99283
7
- data.tar.gz: 71a7ca9f7d4be773d13c6ec619f3a463019a61facd4ca2cf34e30da19ec4270d07ac9cf9618165b14b69f2d36b6eee4b19c61567730dbca632cbf1fff4441903
6
+ metadata.gz: 39275a0949dabb7e47b4f5bcfffe077e673ee15f740eb416d442a8d3516ebe2e27c8dd98198f7f66b5e51234cda8182bff7da8555d54775618fe8246b44c4b84
7
+ data.tar.gz: 1a7ff3940c9d0b044392812564fc99531a597281337e62d0d22cb8b593c05fdfd2480223ec21cd36c7fe07a58347510b73f7f0e9bca9b4f59e46bd95f5730954
data/README.md CHANGED
@@ -22,29 +22,30 @@ Or install it yourself as:
22
22
  You can test the below code using a utility such as telnet (telnet localhost 9000), entering some text, and then killing telnet.
23
23
 
24
24
  # Create a custom connection actor class.
25
- class EchoConnection < Tribe::EM::Connection
25
+ class EchoConn < Tribe::EM::Connection
26
26
  private
27
-
28
- def on_post_init(event)
29
- puts "Actor (#{identifier}) connected to client using thread (#{Thread.current.object_id})."
27
+ def exception_handler(e)
30
28
  super
29
+ puts concat_e("EchoConn (#{identifier}) died.", e)
31
30
  end
32
31
 
33
- def on_receive_data(event)
34
- puts "Actor (#{identifier}) received data (#{event.data}) using thread (#{Thread.current.object_id})."
35
- write(event.data)
36
- enqueue(:shutdown)
37
- super
32
+ def post_init_handler
33
+ puts "Actor (#{identifier}) connected to client using thread (#{Thread.current.object_id})."
38
34
  end
39
35
 
40
- def on_unbind(event)
36
+ def receive_data_handler(data)
37
+ puts "Actor (#{identifier}) received data (#{data}) using thread (#{Thread.current.object_id})."
38
+ write(data)
39
+ shutdown!
40
+ end
41
+
42
+ def unbind_handler
41
43
  puts "Actor (#{identifier}) disconnected from client using thread (#{Thread.current.object_id})."
42
- super
43
44
  end
44
45
  end
45
-
46
+
46
47
  # Create your server actor.
47
- server = Tribe::EM::TcpServer.new('localhost', 9000, EchoConnection)
48
+ server = Tribe::EM::TcpServer.new('localhost', 9000, EchoConn)
48
49
 
49
50
  ## Customization
50
51
 
@@ -15,7 +15,7 @@ module Tribe
15
15
  end
16
16
 
17
17
  #
18
- # EM Callbacks. Don't call these directly.
18
+ # EM Callbacks.
19
19
  #
20
20
 
21
21
  public
@@ -9,44 +9,59 @@ module Tribe
9
9
  private
10
10
 
11
11
  def initialize(options = {})
12
- @actor_proxy = options[:actor_proxy] || raise('You must provide an actor proxy.')
12
+ @_actor_proxy = options[:actor_proxy] || raise('You must provide an actor proxy.')
13
13
 
14
14
  super
15
15
  end
16
16
 
17
- # Override and call super as necessary.
17
+ def write(data)
18
+ @_actor_proxy.write(data)
19
+ end
20
+
21
+ def close(after_writing = false)
22
+ @_actor_proxy.close(after_writing)
23
+ end
24
+
25
+ #
26
+ # Command handlers.
27
+ #
28
+
18
29
  def on_post_init(event)
30
+ post_init_handler
19
31
  end
20
32
 
21
- # Override and call super as necessary.
22
33
  def on_receive_data(event)
34
+ receive_data_handler(event.data)
23
35
  end
24
36
 
25
- # Override and call super as necessary.
26
37
  def on_unbind(event)
27
38
  shutdown!
39
+ unbind_handler
28
40
  end
29
41
 
30
- # Override and call super as necessary.
42
+ #
43
+ # System handlers.
44
+ #
45
+
31
46
  def exception_handler(e)
32
47
  super
33
48
 
34
49
  close
35
50
  end
36
51
 
37
- # Override and call super as necessary.
38
52
  def shutdown_handler(event)
39
53
  super
40
54
 
41
55
  close(true)
42
56
  end
43
57
 
44
- def write(data)
45
- @actor_proxy.write(data)
58
+ def post_init_handler
46
59
  end
47
60
 
48
- def close(after_writing = false)
49
- @actor_proxy.close(after_writing)
61
+ def receive_data_handler(data)
62
+ end
63
+
64
+ def unbind_handler
50
65
  end
51
66
  end
52
67
  end
@@ -1,5 +1,5 @@
1
1
  module Tribe
2
2
  module EM
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tribe_em
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Remesch