eventmachine 0.12.6-x86-mswin32-60 → 0.12.8-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/{docs/README → README} +21 -13
- data/Rakefile +14 -4
- data/docs/DEFERRABLES +0 -5
- data/docs/INSTALL +2 -4
- data/docs/LEGAL +1 -1
- data/docs/LIGHTWEIGHT_CONCURRENCY +0 -2
- data/docs/PURE_RUBY +0 -2
- data/docs/RELEASE_NOTES +0 -2
- data/docs/SMTP +0 -7
- data/docs/SPAWNED_PROCESSES +0 -4
- data/docs/TODO +0 -2
- data/eventmachine.gemspec +41 -32
- data/examples/ex_channel.rb +43 -0
- data/examples/ex_queue.rb +2 -0
- data/examples/helper.rb +2 -0
- data/ext/cmain.cpp +685 -586
- data/ext/cplusplus.cpp +15 -6
- data/ext/ed.cpp +1732 -1522
- data/ext/ed.h +407 -380
- data/ext/em.cpp +2263 -1937
- data/ext/em.h +223 -186
- data/ext/eventmachine.h +111 -98
- data/ext/eventmachine_cpp.h +1 -0
- data/ext/extconf.rb +4 -0
- data/ext/kb.cpp +81 -82
- data/ext/pipe.cpp +349 -351
- data/ext/project.h +21 -0
- data/ext/rubymain.cpp +1047 -847
- data/ext/ssl.cpp +38 -1
- data/ext/ssl.h +5 -1
- data/java/src/com/rubyeventmachine/Application.java +7 -3
- data/java/src/com/rubyeventmachine/EmReactor.java +16 -1
- data/java/src/com/rubyeventmachine/tests/ConnectTest.java +25 -3
- data/lib/{protocols → em}/buftok.rb +16 -5
- data/lib/em/callback.rb +26 -0
- data/lib/em/channel.rb +57 -0
- data/lib/em/connection.rb +505 -0
- data/lib/em/deferrable.rb +144 -165
- data/lib/em/file_watch.rb +54 -0
- data/lib/em/future.rb +24 -25
- data/lib/em/messages.rb +1 -1
- data/lib/em/process_watch.rb +44 -0
- data/lib/em/processes.rb +119 -113
- data/lib/em/protocols.rb +35 -0
- data/lib/em/protocols/header_and_content.rb +138 -0
- data/lib/em/protocols/httpclient.rb +263 -0
- data/lib/em/protocols/httpclient2.rb +582 -0
- data/lib/{protocols → em/protocols}/line_and_text.rb +2 -2
- data/lib/em/protocols/linetext2.rb +160 -0
- data/lib/{protocols → em/protocols}/memcache.rb +37 -7
- data/lib/em/protocols/object_protocol.rb +39 -0
- data/lib/em/protocols/postgres3.rb +247 -0
- data/lib/em/protocols/saslauth.rb +175 -0
- data/lib/em/protocols/smtpclient.rb +331 -0
- data/lib/em/protocols/smtpserver.rb +547 -0
- data/lib/em/protocols/stomp.rb +200 -0
- data/lib/{protocols → em/protocols}/tcptest.rb +21 -25
- data/lib/em/queue.rb +61 -0
- data/lib/em/spawnable.rb +53 -56
- data/lib/em/streamer.rb +92 -74
- data/lib/em/timers.rb +55 -0
- data/lib/em/version.rb +3 -0
- data/lib/eventmachine.rb +1636 -1926
- data/lib/evma.rb +1 -1
- data/lib/jeventmachine.rb +106 -101
- data/lib/pr_eventmachine.rb +47 -36
- data/tasks/project.rake +2 -1
- data/tests/client.crt +31 -0
- data/tests/client.key +51 -0
- data/tests/test_attach.rb +18 -0
- data/tests/test_basic.rb +285 -231
- data/tests/test_channel.rb +63 -0
- data/tests/test_connection_count.rb +2 -2
- data/tests/test_epoll.rb +162 -163
- data/tests/test_errors.rb +36 -36
- data/tests/test_exc.rb +22 -25
- data/tests/test_file_watch.rb +49 -0
- data/tests/test_futures.rb +77 -93
- data/tests/test_hc.rb +2 -2
- data/tests/test_httpclient.rb +55 -52
- data/tests/test_httpclient2.rb +153 -155
- data/tests/test_inactivity_timeout.rb +30 -0
- data/tests/test_kb.rb +8 -9
- data/tests/test_ltp2.rb +274 -277
- data/tests/test_next_tick.rb +135 -109
- data/tests/test_object_protocol.rb +37 -0
- data/tests/test_process_watch.rb +48 -0
- data/tests/test_processes.rb +128 -95
- data/tests/test_proxy_connection.rb +92 -0
- data/tests/test_pure.rb +1 -5
- data/tests/test_queue.rb +44 -0
- data/tests/test_running.rb +9 -14
- data/tests/test_sasl.rb +32 -34
- data/tests/test_send_file.rb +175 -176
- data/tests/test_servers.rb +37 -41
- data/tests/test_smtpserver.rb +47 -55
- data/tests/test_spawn.rb +284 -291
- data/tests/test_ssl_args.rb +1 -1
- data/tests/test_ssl_methods.rb +1 -1
- data/tests/test_ssl_verify.rb +82 -0
- data/tests/test_timers.rb +81 -88
- data/tests/test_ud.rb +0 -7
- data/tests/testem.rb +1 -1
- metadata +52 -36
- data/lib/em/eventable.rb +0 -39
- data/lib/eventmachine_version.rb +0 -31
- data/lib/protocols/header_and_content.rb +0 -129
- data/lib/protocols/httpcli2.rb +0 -803
- data/lib/protocols/httpclient.rb +0 -270
- data/lib/protocols/linetext2.rb +0 -161
- data/lib/protocols/postgres.rb +0 -261
- data/lib/protocols/saslauth.rb +0 -179
- data/lib/protocols/smtpclient.rb +0 -308
- data/lib/protocols/smtpserver.rb +0 -556
- data/lib/protocols/stomp.rb +0 -153
- data/tests/test_eventables.rb +0 -77
data/lib/protocols/stomp.rb
DELETED
@@ -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
|
-
|
data/tests/test_eventables.rb
DELETED
@@ -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
|
-
|