eventmachine 0.12.6-java → 0.12.8-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/{docs/README → README} +21 -13
  2. data/Rakefile +5 -3
  3. data/docs/DEFERRABLES +0 -5
  4. data/docs/INSTALL +2 -4
  5. data/docs/LEGAL +1 -1
  6. data/docs/LIGHTWEIGHT_CONCURRENCY +0 -2
  7. data/docs/PURE_RUBY +0 -2
  8. data/docs/RELEASE_NOTES +0 -2
  9. data/docs/SMTP +0 -7
  10. data/docs/SPAWNED_PROCESSES +0 -4
  11. data/docs/TODO +0 -2
  12. data/eventmachine.gemspec +17 -8
  13. data/examples/ex_channel.rb +43 -0
  14. data/examples/ex_queue.rb +2 -0
  15. data/examples/helper.rb +2 -0
  16. data/ext/cmain.cpp +119 -20
  17. data/ext/cplusplus.cpp +15 -6
  18. data/ext/ed.cpp +303 -93
  19. data/ext/ed.h +49 -22
  20. data/ext/em.cpp +368 -42
  21. data/ext/em.h +43 -6
  22. data/ext/eventmachine.h +21 -8
  23. data/ext/eventmachine_cpp.h +1 -0
  24. data/ext/extconf.rb +4 -0
  25. data/ext/kb.cpp +1 -2
  26. data/ext/pipe.cpp +1 -3
  27. data/ext/project.h +21 -0
  28. data/ext/rubymain.cpp +232 -32
  29. data/ext/ssl.cpp +38 -1
  30. data/ext/ssl.h +5 -1
  31. data/java/src/com/rubyeventmachine/Application.java +7 -3
  32. data/java/src/com/rubyeventmachine/EmReactor.java +16 -1
  33. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +25 -3
  34. data/lib/{protocols → em}/buftok.rb +16 -5
  35. data/lib/em/callback.rb +26 -0
  36. data/lib/em/channel.rb +57 -0
  37. data/lib/em/connection.rb +505 -0
  38. data/lib/em/deferrable.rb +144 -165
  39. data/lib/em/file_watch.rb +54 -0
  40. data/lib/em/future.rb +24 -25
  41. data/lib/em/messages.rb +1 -1
  42. data/lib/em/process_watch.rb +44 -0
  43. data/lib/em/processes.rb +58 -52
  44. data/lib/em/protocols.rb +35 -0
  45. data/lib/em/protocols/header_and_content.rb +138 -0
  46. data/lib/em/protocols/httpclient.rb +263 -0
  47. data/lib/em/protocols/httpclient2.rb +582 -0
  48. data/lib/{protocols → em/protocols}/line_and_text.rb +2 -2
  49. data/lib/em/protocols/linetext2.rb +160 -0
  50. data/lib/{protocols → em/protocols}/memcache.rb +37 -7
  51. data/lib/em/protocols/object_protocol.rb +39 -0
  52. data/lib/em/protocols/postgres3.rb +247 -0
  53. data/lib/em/protocols/saslauth.rb +175 -0
  54. data/lib/em/protocols/smtpclient.rb +331 -0
  55. data/lib/em/protocols/smtpserver.rb +547 -0
  56. data/lib/em/protocols/stomp.rb +200 -0
  57. data/lib/{protocols → em/protocols}/tcptest.rb +21 -25
  58. data/lib/em/queue.rb +61 -0
  59. data/lib/em/spawnable.rb +53 -56
  60. data/lib/em/streamer.rb +92 -74
  61. data/lib/em/timers.rb +55 -0
  62. data/lib/em/version.rb +3 -0
  63. data/lib/eventmachine.rb +1008 -1298
  64. data/lib/evma.rb +1 -1
  65. data/lib/jeventmachine.rb +106 -101
  66. data/lib/pr_eventmachine.rb +47 -36
  67. data/tasks/project.rake +2 -1
  68. data/tests/client.crt +31 -0
  69. data/tests/client.key +51 -0
  70. data/tests/test_attach.rb +18 -0
  71. data/tests/test_basic.rb +108 -54
  72. data/tests/test_channel.rb +63 -0
  73. data/tests/test_connection_count.rb +2 -2
  74. data/tests/test_epoll.rb +109 -110
  75. data/tests/test_errors.rb +36 -36
  76. data/tests/test_exc.rb +22 -25
  77. data/tests/test_file_watch.rb +49 -0
  78. data/tests/test_futures.rb +77 -93
  79. data/tests/test_hc.rb +2 -2
  80. data/tests/test_httpclient.rb +55 -52
  81. data/tests/test_httpclient2.rb +110 -112
  82. data/tests/test_inactivity_timeout.rb +30 -0
  83. data/tests/test_kb.rb +8 -9
  84. data/tests/test_ltp2.rb +274 -277
  85. data/tests/test_next_tick.rb +91 -65
  86. data/tests/test_object_protocol.rb +37 -0
  87. data/tests/test_process_watch.rb +48 -0
  88. data/tests/test_processes.rb +56 -23
  89. data/tests/test_proxy_connection.rb +92 -0
  90. data/tests/test_pure.rb +1 -5
  91. data/tests/test_queue.rb +44 -0
  92. data/tests/test_running.rb +9 -14
  93. data/tests/test_sasl.rb +32 -34
  94. data/tests/test_send_file.rb +175 -176
  95. data/tests/test_servers.rb +37 -41
  96. data/tests/test_smtpserver.rb +47 -55
  97. data/tests/test_spawn.rb +284 -291
  98. data/tests/test_ssl_args.rb +1 -1
  99. data/tests/test_ssl_methods.rb +1 -1
  100. data/tests/test_ssl_verify.rb +82 -0
  101. data/tests/test_timers.rb +81 -88
  102. data/tests/test_ud.rb +0 -7
  103. data/tests/testem.rb +1 -1
  104. metadata +52 -36
  105. data/lib/em/eventable.rb +0 -39
  106. data/lib/eventmachine_version.rb +0 -31
  107. data/lib/protocols/header_and_content.rb +0 -129
  108. data/lib/protocols/httpcli2.rb +0 -803
  109. data/lib/protocols/httpclient.rb +0 -270
  110. data/lib/protocols/linetext2.rb +0 -161
  111. data/lib/protocols/postgres.rb +0 -261
  112. data/lib/protocols/saslauth.rb +0 -179
  113. data/lib/protocols/smtpclient.rb +0 -308
  114. data/lib/protocols/smtpserver.rb +0 -556
  115. data/lib/protocols/stomp.rb +0 -153
  116. data/tests/test_eventables.rb +0 -77
@@ -1,153 +0,0 @@
1
- # $Id$
2
- #
3
- # Author:: Francis Cianfrocca (gmail: blackhedd)
4
- # Homepage:: http://rubyeventmachine.com
5
- # Date:: 15 November 2006
6
- #
7
- # See EventMachine and EventMachine::Connection for documentation and
8
- # usage examples.
9
- #
10
- #----------------------------------------------------------------------------
11
- #
12
- # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
- # Gmail: blackhedd
14
- #
15
- # This program is free software; you can redistribute it and/or modify
16
- # it under the terms of either: 1) the GNU General Public License
17
- # as published by the Free Software Foundation; either version 2 of the
18
- # License, or (at your option) any later version; or 2) Ruby's License.
19
- #
20
- # See the file COPYING for complete licensing information.
21
- #
22
- #---------------------------------------------------------------------------
23
- #
24
- #
25
- #
26
-
27
-
28
-
29
- module EventMachine
30
- module Protocols
31
-
32
- # Implements Stomp (http://docs.codehaus.org/display/STOMP/Protocol).
33
- #
34
- # == Usage example
35
- #
36
- # class StompClient < EM::Connection
37
- # include EM::Protocols::Stomp
38
- #
39
- # def connection_completed
40
- # connect :login => 'guest', :passcode => 'guest'
41
- # end
42
- #
43
- # def receive_msg msg
44
- # if msg.command == "CONNECTED"
45
- # subscribe '/some/topic'
46
- # else
47
- # p ['got a message', msg]
48
- # puts msg.body
49
- # end
50
- # end
51
- # end
52
- #
53
- # EM.run{
54
- # EM.connect 'localhost', 61613, StompClient
55
- # }
56
- #
57
- module Stomp
58
- include LineText2
59
-
60
- class Message
61
- attr_accessor :command, :header, :body
62
- def initialize
63
- @header = {}
64
- @state = :precommand
65
- @content_length = nil
66
- end
67
- def consume_line line
68
- if @state == :precommand
69
- unless line =~ /\A\s*\Z/
70
- @command = line
71
- @state = :headers
72
- end
73
- elsif @state == :headers
74
- if line == ""
75
- if @content_length
76
- yield( [:sized_text, @content_length+1] )
77
- else
78
- @state = :body
79
- yield( [:unsized_text] )
80
- end
81
- elsif line =~ /\A([^:]+):(.+)\Z/
82
- k = $1.dup.strip
83
- v = $2.dup.strip
84
- @header[k] = v
85
- if k == "content-length"
86
- @content_length = v.to_i
87
- end
88
- else
89
- # This is a protocol error. How to signal it?
90
- end
91
- elsif @state == :body
92
- @body = line
93
- yield( [:dispatch] )
94
- end
95
- end
96
- end
97
-
98
- def send_frame verb, headers={}, body=""
99
- ary = [verb, "\n"]
100
- headers.each {|k,v| ary << "#{k}:#{v}\n" }
101
- ary << "content-length: #{body.to_s.length}\n"
102
- ary << "content-type: text/plain; charset=UTF-8\n"
103
- ary << "\n"
104
- ary << body.to_s
105
- ary << "\0"
106
- send_data ary.join
107
- end
108
-
109
- def receive_line line
110
- @stomp_initialized || init_message_reader
111
- @stomp_message.consume_line(line) {|outcome|
112
- if outcome.first == :sized_text
113
- set_text_mode outcome[1]
114
- elsif outcome.first == :unsized_text
115
- set_delimiter "\0"
116
- elsif outcome.first == :dispatch
117
- receive_msg(@stomp_message) if respond_to?(:receive_msg)
118
- init_message_reader
119
- end
120
- }
121
- end
122
- def receive_binary_data data
123
- @stomp_message.body = data[0..-2]
124
- receive_msg(@stomp_message) if respond_to?(:receive_msg)
125
- init_message_reader
126
- end
127
-
128
- def init_message_reader
129
- @stomp_initialized = true
130
- set_delimiter "\n"
131
- set_line_mode
132
- @stomp_message = Message.new
133
- end
134
-
135
-
136
- # STOMP verbs
137
- def connect parms={}
138
- send_frame "CONNECT", parms
139
- end
140
- def send destination, body, parms={}
141
- send_frame "SEND", parms.merge( :destination=>destination ), body.to_s
142
- end
143
- def subscribe dest, ack=false
144
- send_frame "SUBSCRIBE", {:destination=>dest, :ack=>(ack ? "client" : "auto")}
145
- end
146
- def ack msgid
147
- send_frame "ACK", { :'message-id'=> msgid }
148
- end
149
-
150
- end
151
- end
152
- end
153
-
@@ -1,77 +0,0 @@
1
- # $Id$
2
- #
3
- # Author:: Francis Cianfrocca (gmail: blackhedd)
4
- # Homepage:: http://rubyeventmachine.com
5
- # Date:: 8 April 2006
6
- #
7
- # See EventMachine and EventMachine::Connection for documentation and
8
- # usage examples.
9
- #
10
- #----------------------------------------------------------------------------
11
- #
12
- # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
- # Gmail: blackhedd
14
- #
15
- # This program is free software; you can redistribute it and/or modify
16
- # it under the terms of either: 1) the GNU General Public License
17
- # as published by the Free Software Foundation; either version 2 of the
18
- # License, or (at your option) any later version; or 2) Ruby's License.
19
- #
20
- # See the file COPYING for complete licensing information.
21
- #
22
- #---------------------------------------------------------------------------
23
- #
24
- #
25
- #
26
-
27
- $:.unshift "../lib"
28
- require 'eventmachine'
29
-
30
- class TestEventables < Test::Unit::TestCase
31
-
32
- class EvTest
33
- include EventMachine::Eventable
34
- end
35
-
36
- def setup
37
- end
38
-
39
- def teardown
40
- end
41
-
42
- def test_a; end # shut up rake until we define a test.
43
-
44
- # TODO, this idea is still half-baked.
45
- def xxx_test_a
46
- n = 0
47
- tester = EvTest.new
48
- tester.listen_event( :fire1 ) {|arg|
49
- n = 1 if arg == "$"
50
- EventMachine.stop
51
- }
52
- tester.post_event( :fire1, "$" )
53
-
54
- EventMachine.run {
55
- EventMachine::add_timer(1) {EventMachine.stop}
56
- }
57
-
58
- assert_equal( 1, n )
59
- end
60
-
61
- end
62
-
63
-
64
- #--------------------------------------
65
-
66
- if __FILE__ == $0
67
- require 'test/unit/testsuite'
68
- require 'test/unit/ui/console/testrunner'
69
-
70
- runner = Test::Unit::UI::Console::TestRunner
71
- suite = Test::Unit::TestSuite.new("name")
72
- ObjectSpace.each_object(Class) do |testcase|
73
- suite << testcase.suite if testcase < Test::Unit::TestCase
74
- end
75
- runner.run(suite)
76
- end
77
-