eventmachine 0.12.10-x86-mswin32-60 → 1.0.0.beta.2-x86-mswin32-60
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.
- data/.gitignore +2 -0
- data/Gemfile +1 -0
- data/README +80 -81
- data/Rakefile +7 -370
- data/docs/COPYING +60 -60
- data/docs/ChangeLog +211 -211
- data/docs/DEFERRABLES +246 -133
- data/docs/EPOLL +141 -141
- data/docs/GNU +281 -281
- data/docs/INSTALL +13 -13
- data/docs/KEYBOARD +42 -38
- data/docs/LEGAL +25 -25
- data/docs/LIGHTWEIGHT_CONCURRENCY +130 -70
- data/docs/PURE_RUBY +75 -75
- data/docs/RELEASE_NOTES +94 -94
- data/docs/SMTP +4 -2
- data/docs/SPAWNED_PROCESSES +148 -89
- data/docs/TODO +8 -8
- data/eventmachine.gemspec +19 -26
- data/examples/ex_channel.rb +42 -42
- data/examples/ex_queue.rb +2 -2
- data/examples/ex_tick_loop_array.rb +15 -0
- data/examples/ex_tick_loop_counter.rb +32 -0
- data/examples/helper.rb +1 -1
- data/ext/binder.cpp +0 -1
- data/ext/cmain.cpp +36 -25
- data/ext/ed.cpp +104 -113
- data/ext/ed.h +24 -30
- data/ext/em.cpp +349 -283
- data/ext/em.h +25 -29
- data/ext/eventmachine.h +5 -4
- data/ext/extconf.rb +58 -49
- data/ext/fastfilereader/extconf.rb +5 -3
- data/ext/fastfilereader/mapper.cpp +214 -214
- data/ext/fastfilereader/mapper.h +59 -59
- data/ext/fastfilereader/rubymain.cpp +127 -127
- data/ext/kb.cpp +1 -3
- data/ext/page.cpp +107 -107
- data/ext/page.h +51 -51
- data/ext/pipe.cpp +9 -11
- data/ext/project.h +12 -8
- data/ext/rubymain.cpp +138 -104
- data/java/.classpath +8 -8
- data/java/.project +17 -17
- data/java/src/com/rubyeventmachine/EmReactor.java +1 -0
- data/java/src/com/rubyeventmachine/EmReactorException.java +40 -40
- data/lib/em/buftok.rb +138 -138
- data/lib/em/callback.rb +25 -25
- data/lib/em/channel.rb +1 -1
- data/lib/em/connection.rb +6 -1
- data/lib/em/deferrable.rb +16 -2
- data/lib/em/file_watch.rb +53 -53
- data/lib/em/future.rb +61 -61
- data/lib/em/iterator.rb +270 -0
- data/lib/em/messages.rb +66 -66
- data/lib/em/process_watch.rb +43 -43
- data/lib/em/protocols.rb +1 -1
- data/lib/em/protocols/header_and_content.rb +138 -138
- data/lib/em/protocols/httpclient.rb +267 -262
- data/lib/em/protocols/line_protocol.rb +28 -0
- data/lib/em/protocols/memcache.rb +322 -322
- data/lib/em/protocols/postgres3.rb +247 -247
- data/lib/em/protocols/saslauth.rb +175 -175
- data/lib/em/protocols/smtpserver.rb +640 -547
- data/lib/em/protocols/stomp.rb +200 -200
- data/lib/em/protocols/tcptest.rb +52 -52
- data/lib/{pr_eventmachine.rb → em/pure_ruby.rb} +1013 -1022
- data/lib/em/queue.rb +1 -0
- data/lib/em/spawnable.rb +85 -85
- data/lib/em/streamer.rb +130 -130
- data/lib/em/tick_loop.rb +85 -0
- data/lib/em/timers.rb +2 -1
- data/lib/em/version.rb +1 -1
- data/lib/eventmachine.rb +40 -84
- data/lib/jeventmachine.rb +2 -1
- data/lib/rubyeventmachine.rb +2 -0
- data/setup.rb +1585 -1585
- data/tasks/doc.rake +30 -0
- data/tasks/package.rake +85 -0
- data/tasks/test.rake +6 -0
- data/tests/client.crt +31 -31
- data/tests/client.key +51 -51
- data/tests/test_attach.rb +13 -3
- data/tests/test_basic.rb +60 -95
- data/tests/test_channel.rb +3 -2
- data/tests/test_defer.rb +49 -47
- data/tests/test_deferrable.rb +35 -0
- data/tests/test_error_handler.rb +35 -35
- data/tests/test_errors.rb +82 -82
- data/tests/test_exc.rb +55 -55
- data/tests/test_file_watch.rb +49 -49
- data/tests/test_futures.rb +198 -198
- data/tests/test_handler_check.rb +36 -36
- data/tests/test_hc.rb +190 -218
- data/tests/test_httpclient.rb +227 -218
- data/tests/test_httpclient2.rb +3 -2
- data/tests/test_inactivity_timeout.rb +3 -3
- data/tests/test_kb.rb +60 -60
- data/tests/test_ltp.rb +13 -5
- data/tests/test_ltp2.rb +317 -317
- data/tests/test_next_tick.rb +1 -1
- data/tests/test_object_protocol.rb +36 -36
- data/tests/test_pending_connect_timeout.rb +2 -2
- data/tests/test_process_watch.rb +50 -48
- data/tests/test_proxy_connection.rb +52 -0
- data/tests/test_pure.rb +134 -125
- data/tests/test_queue.rb +44 -44
- data/tests/test_running.rb +42 -42
- data/tests/test_sasl.rb +72 -72
- data/tests/test_send_file.rb +251 -242
- data/tests/test_servers.rb +76 -76
- data/tests/test_smtpclient.rb +83 -83
- data/tests/test_smtpserver.rb +85 -85
- data/tests/test_spawn.rb +322 -322
- data/tests/test_ssl_methods.rb +49 -49
- data/tests/test_ssl_verify.rb +82 -82
- data/tests/test_tick_loop.rb +59 -0
- data/tests/test_timers.rb +13 -15
- data/tests/test_ud.rb +36 -36
- data/tests/testem.rb +31 -31
- metadata +66 -51
- data/ext/cplusplus.cpp +0 -202
- data/ext/emwin.cpp +0 -300
- data/ext/emwin.h +0 -94
- data/ext/epoll.cpp +0 -26
- data/ext/epoll.h +0 -25
- data/ext/eventmachine_cpp.h +0 -96
- data/ext/files.cpp +0 -94
- data/ext/files.h +0 -65
- data/ext/sigs.cpp +0 -89
- data/ext/sigs.h +0 -32
- data/java/src/com/rubyeventmachine/application/Application.java +0 -194
- data/java/src/com/rubyeventmachine/application/Connection.java +0 -74
- data/java/src/com/rubyeventmachine/application/ConnectionFactory.java +0 -37
- data/java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java +0 -46
- data/java/src/com/rubyeventmachine/application/PeriodicTimer.java +0 -38
- data/java/src/com/rubyeventmachine/application/Timer.java +0 -54
- data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +0 -109
- data/java/src/com/rubyeventmachine/tests/ConnectTest.java +0 -148
- data/java/src/com/rubyeventmachine/tests/EMTest.java +0 -80
- data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +0 -53
- data/java/src/com/rubyeventmachine/tests/TestServers.java +0 -75
- data/java/src/com/rubyeventmachine/tests/TestTimers.java +0 -90
- data/lib/evma.rb +0 -32
- data/lib/evma/callback.rb +0 -32
- data/lib/evma/container.rb +0 -75
- data/lib/evma/factory.rb +0 -77
- data/lib/evma/protocol.rb +0 -87
- data/lib/evma/reactor.rb +0 -48
- data/web/whatis +0 -7
data/tests/testem.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
# $Id$
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
module EmTestRunner
|
6
|
-
@em_root = File.expand_path(File.dirname(__FILE__) + '/../')
|
7
|
-
@lib_dir = File.join(@em_root, 'lib')
|
8
|
-
@ext_dir = File.join(@em_root, 'ext')
|
9
|
-
@java_dir = File.join(@em_root, 'java')
|
10
|
-
|
11
|
-
def self.run(glob = 'test_*.rb')
|
12
|
-
$:.unshift(@lib_dir)
|
13
|
-
$:.unshift(@ext_dir)
|
14
|
-
$:.unshift(@java_dir)
|
15
|
-
|
16
|
-
case glob
|
17
|
-
when Array
|
18
|
-
files = glob
|
19
|
-
else
|
20
|
-
files = Dir[File.dirname(__FILE__) + '/' + glob]
|
21
|
-
end
|
22
|
-
|
23
|
-
files.each do |tc|
|
24
|
-
require tc
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
if __FILE__ == $0
|
30
|
-
EmTestRunner.run
|
31
|
-
end
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
module EmTestRunner
|
6
|
+
@em_root = File.expand_path(File.dirname(__FILE__) + '/../')
|
7
|
+
@lib_dir = File.join(@em_root, 'lib')
|
8
|
+
@ext_dir = File.join(@em_root, 'ext')
|
9
|
+
@java_dir = File.join(@em_root, 'java')
|
10
|
+
|
11
|
+
def self.run(glob = 'test_*.rb')
|
12
|
+
$:.unshift(@lib_dir)
|
13
|
+
$:.unshift(@ext_dir)
|
14
|
+
$:.unshift(@java_dir)
|
15
|
+
|
16
|
+
case glob
|
17
|
+
when Array
|
18
|
+
files = glob
|
19
|
+
else
|
20
|
+
files = Dir[File.dirname(__FILE__) + '/' + glob]
|
21
|
+
end
|
22
|
+
|
23
|
+
files.each do |tc|
|
24
|
+
require tc
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
if __FILE__ == $0
|
30
|
+
EmTestRunner.run
|
31
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,51 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventmachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: true
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- beta
|
10
|
+
- 2
|
11
|
+
version: 1.0.0.beta.2
|
5
12
|
platform: x86-mswin32-60
|
6
13
|
authors:
|
7
14
|
- Francis Cianfrocca
|
15
|
+
- Aman Gupta
|
8
16
|
autorequire:
|
9
17
|
bindir: bin
|
10
18
|
cert_chain: []
|
11
19
|
|
12
|
-
date:
|
20
|
+
date: 2010-11-13 00:00:00 +05:30
|
13
21
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
name: rake-compiler
|
25
|
+
prerelease: false
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
description: |-
|
36
|
+
EventMachine implements a fast, single-threaded engine for arbitrary network
|
37
|
+
communications. It's extremely easy to use in Ruby. EventMachine wraps all
|
38
|
+
interactions with IP sockets, allowing programs to concentrate on the
|
39
|
+
implementation of network protocols. It can be used to create both network
|
40
|
+
servers and clients. To create a server or client, a Ruby program only needs
|
41
|
+
to specify the IP address and port, and provide a Module that implements the
|
42
|
+
communications protocol. Implementations of several standard network protocols
|
43
|
+
are provided with the package, primarily to serve as examples. The real goal
|
44
|
+
of EventMachine is to enable programs to easily interface with other programs
|
45
|
+
using TCP/IP, especially if custom protocols are required.
|
46
|
+
email:
|
47
|
+
- garbagecat10@gmail.com
|
48
|
+
- aman@tmm1.net
|
18
49
|
executables: []
|
19
50
|
|
20
51
|
extensions: []
|
@@ -23,6 +54,7 @@ extra_rdoc_files: []
|
|
23
54
|
|
24
55
|
files:
|
25
56
|
- .gitignore
|
57
|
+
- Gemfile
|
26
58
|
- README
|
27
59
|
- Rakefile
|
28
60
|
- docs/COPYING
|
@@ -42,36 +74,28 @@ files:
|
|
42
74
|
- eventmachine.gemspec
|
43
75
|
- examples/ex_channel.rb
|
44
76
|
- examples/ex_queue.rb
|
77
|
+
- examples/ex_tick_loop_array.rb
|
78
|
+
- examples/ex_tick_loop_counter.rb
|
45
79
|
- examples/helper.rb
|
46
80
|
- ext/binder.cpp
|
47
81
|
- ext/binder.h
|
48
82
|
- ext/cmain.cpp
|
49
|
-
- ext/cplusplus.cpp
|
50
83
|
- ext/ed.cpp
|
51
84
|
- ext/ed.h
|
52
85
|
- ext/em.cpp
|
53
86
|
- ext/em.h
|
54
|
-
- ext/emwin.cpp
|
55
|
-
- ext/emwin.h
|
56
|
-
- ext/epoll.cpp
|
57
|
-
- ext/epoll.h
|
58
87
|
- ext/eventmachine.h
|
59
|
-
- ext/eventmachine_cpp.h
|
60
88
|
- ext/extconf.rb
|
61
89
|
- ext/fastfilereader/extconf.rb
|
62
90
|
- ext/fastfilereader/mapper.cpp
|
63
91
|
- ext/fastfilereader/mapper.h
|
64
92
|
- ext/fastfilereader/rubymain.cpp
|
65
|
-
- ext/files.cpp
|
66
|
-
- ext/files.h
|
67
93
|
- ext/kb.cpp
|
68
94
|
- ext/page.cpp
|
69
95
|
- ext/page.h
|
70
96
|
- ext/pipe.cpp
|
71
97
|
- ext/project.h
|
72
98
|
- ext/rubymain.cpp
|
73
|
-
- ext/sigs.cpp
|
74
|
-
- ext/sigs.h
|
75
99
|
- ext/ssl.cpp
|
76
100
|
- ext/ssl.h
|
77
101
|
- java/.classpath
|
@@ -81,18 +105,6 @@ files:
|
|
81
105
|
- java/src/com/rubyeventmachine/EventableChannel.java
|
82
106
|
- java/src/com/rubyeventmachine/EventableDatagramChannel.java
|
83
107
|
- java/src/com/rubyeventmachine/EventableSocketChannel.java
|
84
|
-
- java/src/com/rubyeventmachine/application/Application.java
|
85
|
-
- java/src/com/rubyeventmachine/application/Connection.java
|
86
|
-
- java/src/com/rubyeventmachine/application/ConnectionFactory.java
|
87
|
-
- java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java
|
88
|
-
- java/src/com/rubyeventmachine/application/PeriodicTimer.java
|
89
|
-
- java/src/com/rubyeventmachine/application/Timer.java
|
90
|
-
- java/src/com/rubyeventmachine/tests/ApplicationTest.java
|
91
|
-
- java/src/com/rubyeventmachine/tests/ConnectTest.java
|
92
|
-
- java/src/com/rubyeventmachine/tests/EMTest.java
|
93
|
-
- java/src/com/rubyeventmachine/tests/TestDatagrams.java
|
94
|
-
- java/src/com/rubyeventmachine/tests/TestServers.java
|
95
|
-
- java/src/com/rubyeventmachine/tests/TestTimers.java
|
96
108
|
- lib/em/buftok.rb
|
97
109
|
- lib/em/callback.rb
|
98
110
|
- lib/em/channel.rb
|
@@ -100,6 +112,7 @@ files:
|
|
100
112
|
- lib/em/deferrable.rb
|
101
113
|
- lib/em/file_watch.rb
|
102
114
|
- lib/em/future.rb
|
115
|
+
- lib/em/iterator.rb
|
103
116
|
- lib/em/messages.rb
|
104
117
|
- lib/em/process_watch.rb
|
105
118
|
- lib/em/processes.rb
|
@@ -108,6 +121,7 @@ files:
|
|
108
121
|
- lib/em/protocols/httpclient.rb
|
109
122
|
- lib/em/protocols/httpclient2.rb
|
110
123
|
- lib/em/protocols/line_and_text.rb
|
124
|
+
- lib/em/protocols/line_protocol.rb
|
111
125
|
- lib/em/protocols/linetext2.rb
|
112
126
|
- lib/em/protocols/memcache.rb
|
113
127
|
- lib/em/protocols/object_protocol.rb
|
@@ -118,22 +132,20 @@ files:
|
|
118
132
|
- lib/em/protocols/socks4.rb
|
119
133
|
- lib/em/protocols/stomp.rb
|
120
134
|
- lib/em/protocols/tcptest.rb
|
135
|
+
- lib/em/pure_ruby.rb
|
121
136
|
- lib/em/queue.rb
|
122
137
|
- lib/em/spawnable.rb
|
123
138
|
- lib/em/streamer.rb
|
139
|
+
- lib/em/tick_loop.rb
|
124
140
|
- lib/em/timers.rb
|
125
141
|
- lib/em/version.rb
|
126
142
|
- lib/eventmachine.rb
|
127
|
-
- lib/evma.rb
|
128
|
-
- lib/evma/callback.rb
|
129
|
-
- lib/evma/container.rb
|
130
|
-
- lib/evma/factory.rb
|
131
|
-
- lib/evma/protocol.rb
|
132
|
-
- lib/evma/reactor.rb
|
133
143
|
- lib/jeventmachine.rb
|
134
|
-
- lib/pr_eventmachine.rb
|
135
144
|
- setup.rb
|
136
145
|
- tasks/cpp.rake_example
|
146
|
+
- tasks/doc.rake
|
147
|
+
- tasks/package.rake
|
148
|
+
- tasks/test.rake
|
137
149
|
- tests/client.crt
|
138
150
|
- tests/client.key
|
139
151
|
- tests/test_attach.rb
|
@@ -141,6 +153,7 @@ files:
|
|
141
153
|
- tests/test_channel.rb
|
142
154
|
- tests/test_connection_count.rb
|
143
155
|
- tests/test_defer.rb
|
156
|
+
- tests/test_deferrable.rb
|
144
157
|
- tests/test_epoll.rb
|
145
158
|
- tests/test_error_handler.rb
|
146
159
|
- tests/test_errors.rb
|
@@ -175,30 +188,28 @@ files:
|
|
175
188
|
- tests/test_ssl_args.rb
|
176
189
|
- tests/test_ssl_methods.rb
|
177
190
|
- tests/test_ssl_verify.rb
|
191
|
+
- tests/test_tick_loop.rb
|
178
192
|
- tests/test_timers.rb
|
179
193
|
- tests/test_ud.rb
|
180
194
|
- tests/testem.rb
|
181
|
-
-
|
182
|
-
- lib/rubyeventmachine.so
|
183
|
-
- lib/fastfilereaderext.so
|
195
|
+
- lib/1.8/rubyeventmachine.so
|
196
|
+
- lib/1.9/rubyeventmachine.so
|
197
|
+
- lib/1.8/fastfilereaderext.so
|
198
|
+
- lib/1.9/fastfilereaderext.so
|
199
|
+
- lib/rubyeventmachine.rb
|
184
200
|
has_rdoc: true
|
185
201
|
homepage: http://rubyeventmachine.com
|
202
|
+
licenses: []
|
203
|
+
|
186
204
|
post_install_message:
|
187
205
|
rdoc_options:
|
188
206
|
- --title
|
189
207
|
- EventMachine
|
190
208
|
- --main
|
191
209
|
- README
|
192
|
-
- --line-numbers
|
193
210
|
- -x
|
194
211
|
- lib/em/version
|
195
212
|
- -x
|
196
|
-
- lib/emva
|
197
|
-
- -x
|
198
|
-
- lib/evma/
|
199
|
-
- -x
|
200
|
-
- lib/pr_eventmachine
|
201
|
-
- -x
|
202
213
|
- lib/jeventmachine
|
203
214
|
require_paths:
|
204
215
|
- lib
|
@@ -206,20 +217,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
206
217
|
requirements:
|
207
218
|
- - ">="
|
208
219
|
- !ruby/object:Gem::Version
|
220
|
+
segments:
|
221
|
+
- 0
|
209
222
|
version: "0"
|
210
|
-
version:
|
211
223
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
224
|
requirements:
|
213
|
-
- - "
|
225
|
+
- - ">"
|
214
226
|
- !ruby/object:Gem::Version
|
215
|
-
|
216
|
-
|
227
|
+
segments:
|
228
|
+
- 1
|
229
|
+
- 3
|
230
|
+
- 1
|
231
|
+
version: 1.3.1
|
217
232
|
requirements: []
|
218
233
|
|
219
234
|
rubyforge_project: eventmachine
|
220
|
-
rubygems_version: 1.3.
|
235
|
+
rubygems_version: 1.3.6
|
221
236
|
signing_key:
|
222
|
-
specification_version:
|
237
|
+
specification_version: 3
|
223
238
|
summary: Ruby/EventMachine library
|
224
239
|
test_files: []
|
225
240
|
|
data/ext/cplusplus.cpp
DELETED
@@ -1,202 +0,0 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
|
3
|
-
$Id$
|
4
|
-
|
5
|
-
File: cplusplus.cpp
|
6
|
-
Date: 27Jul07
|
7
|
-
|
8
|
-
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail: blackhedd
|
10
|
-
|
11
|
-
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of either: 1) the GNU General Public License
|
13
|
-
as published by the Free Software Foundation; either version 2 of the
|
14
|
-
License, or (at your option) any later version; or 2) Ruby's License.
|
15
|
-
|
16
|
-
See the file COPYING for complete licensing information.
|
17
|
-
|
18
|
-
*****************************************************************************/
|
19
|
-
|
20
|
-
|
21
|
-
#include "project.h"
|
22
|
-
|
23
|
-
|
24
|
-
namespace EM {
|
25
|
-
static map<unsigned long, Eventable*> Eventables;
|
26
|
-
static map<unsigned long, void(*)()> Timers;
|
27
|
-
}
|
28
|
-
|
29
|
-
|
30
|
-
/*******
|
31
|
-
EM::Run
|
32
|
-
*******/
|
33
|
-
|
34
|
-
void EM::Run (void (*start_func)())
|
35
|
-
{
|
36
|
-
evma_set_epoll (1);
|
37
|
-
evma_initialize_library (EM::Callback);
|
38
|
-
if (start_func)
|
39
|
-
AddTimer (0, start_func);
|
40
|
-
evma_run_machine();
|
41
|
-
evma_release_library();
|
42
|
-
}
|
43
|
-
|
44
|
-
/************
|
45
|
-
EM::AddTimer
|
46
|
-
************/
|
47
|
-
|
48
|
-
void EM::AddTimer (int milliseconds, void (*func)())
|
49
|
-
{
|
50
|
-
if (func) {
|
51
|
-
const unsigned long sig = evma_install_oneshot_timer (milliseconds);
|
52
|
-
#ifndef HAVE_MAKE_PAIR
|
53
|
-
Timers.insert (map<unsigned long, void(*)()>::value_type (sig, func));
|
54
|
-
#else
|
55
|
-
Timers.insert (make_pair (sig, func));
|
56
|
-
#endif
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
|
61
|
-
/***************
|
62
|
-
EM::StopReactor
|
63
|
-
***************/
|
64
|
-
|
65
|
-
void EM::StopReactor()
|
66
|
-
{
|
67
|
-
evma_stop_machine();
|
68
|
-
}
|
69
|
-
|
70
|
-
|
71
|
-
/********************
|
72
|
-
EM::Acceptor::Accept
|
73
|
-
********************/
|
74
|
-
|
75
|
-
void EM::Acceptor::Accept (const unsigned long signature)
|
76
|
-
{
|
77
|
-
Connection *c = MakeConnection();
|
78
|
-
c->Signature = signature;
|
79
|
-
#ifndef HAVE_MAKE_PAIR
|
80
|
-
Eventables.insert (std::map<unsigned long,EM::Eventable*>::value_type (c->Signature, c));
|
81
|
-
#else
|
82
|
-
Eventables.insert (make_pair (c->Signature, c));
|
83
|
-
#endif
|
84
|
-
c->PostInit();
|
85
|
-
}
|
86
|
-
|
87
|
-
/************************
|
88
|
-
EM::Connection::SendData
|
89
|
-
************************/
|
90
|
-
|
91
|
-
void EM::Connection::SendData (const char *data)
|
92
|
-
{
|
93
|
-
if (data)
|
94
|
-
SendData (data, strlen (data));
|
95
|
-
}
|
96
|
-
|
97
|
-
|
98
|
-
/************************
|
99
|
-
EM::Connection::SendData
|
100
|
-
************************/
|
101
|
-
|
102
|
-
void EM::Connection::SendData (const char *data, int length)
|
103
|
-
{
|
104
|
-
evma_send_data_to_connection (Signature, data, length);
|
105
|
-
}
|
106
|
-
|
107
|
-
|
108
|
-
/*********************
|
109
|
-
EM::Connection::Close
|
110
|
-
*********************/
|
111
|
-
|
112
|
-
void EM::Connection::Close (bool afterWriting)
|
113
|
-
{
|
114
|
-
evma_close_connection (Signature, afterWriting);
|
115
|
-
}
|
116
|
-
|
117
|
-
|
118
|
-
/***************************
|
119
|
-
EM::Connection::BindConnect
|
120
|
-
***************************/
|
121
|
-
|
122
|
-
void EM::Connection::BindConnect (const char *bind_addr, int bind_port, const char *host, int port)
|
123
|
-
{
|
124
|
-
Signature = evma_connect_to_server (bind_addr, bind_port, host, port);
|
125
|
-
#ifndef HAVE_MAKE_PAIR
|
126
|
-
Eventables.insert (std::map<unsigned long,EM::Eventable*>::value_type (Signature, this));
|
127
|
-
#else
|
128
|
-
Eventables.insert (make_pair (Signature, this));
|
129
|
-
#endif
|
130
|
-
}
|
131
|
-
|
132
|
-
/***********************
|
133
|
-
EM::Connection::Connect
|
134
|
-
***********************/
|
135
|
-
|
136
|
-
void EM::Connection::Connect (const char *host, int port)
|
137
|
-
{
|
138
|
-
this->BindConnect(NULL, 0, host, port);
|
139
|
-
}
|
140
|
-
|
141
|
-
/*******************
|
142
|
-
EM::Acceptor::Start
|
143
|
-
*******************/
|
144
|
-
|
145
|
-
void EM::Acceptor::Start (const char *host, int port)
|
146
|
-
{
|
147
|
-
Signature = evma_create_tcp_server (host, port);
|
148
|
-
#ifndef HAVE_MAKE_PAIR
|
149
|
-
Eventables.insert (std::map<unsigned long,EM::Eventable*>::value_type (Signature, this));
|
150
|
-
#else
|
151
|
-
Eventables.insert (make_pair (Signature, this));
|
152
|
-
#endif
|
153
|
-
}
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
/************
|
158
|
-
EM::Callback
|
159
|
-
************/
|
160
|
-
|
161
|
-
void EM::Callback (const unsigned long sig, int ev, const char *data, const unsigned long length)
|
162
|
-
{
|
163
|
-
EM::Eventable *e;
|
164
|
-
void (*f)();
|
165
|
-
|
166
|
-
switch (ev) {
|
167
|
-
case EM_TIMER_FIRED:
|
168
|
-
f = Timers [length]; // actually a binding
|
169
|
-
if (f)
|
170
|
-
(*f)();
|
171
|
-
Timers.erase (length);
|
172
|
-
break;
|
173
|
-
|
174
|
-
case EM_CONNECTION_READ:
|
175
|
-
e = EM::Eventables [sig];
|
176
|
-
e->ReceiveData (data, length);
|
177
|
-
break;
|
178
|
-
|
179
|
-
case EM_CONNECTION_COMPLETED:
|
180
|
-
e = EM::Eventables [sig];
|
181
|
-
e->ConnectionCompleted();
|
182
|
-
break;
|
183
|
-
|
184
|
-
case EM_CONNECTION_ACCEPTED:
|
185
|
-
e = EM::Eventables [sig];
|
186
|
-
e->Accept (length); // actually a binding
|
187
|
-
break;
|
188
|
-
|
189
|
-
case EM_CONNECTION_UNBOUND:
|
190
|
-
e = EM::Eventables [sig];
|
191
|
-
e->Unbind();
|
192
|
-
EM::Eventables.erase (sig);
|
193
|
-
delete e;
|
194
|
-
break;
|
195
|
-
|
196
|
-
case EM_SSL_HANDSHAKE_COMPLETED:
|
197
|
-
e = EM::Eventables [sig];
|
198
|
-
e->SslHandshakeCompleted();
|
199
|
-
break;
|
200
|
-
}
|
201
|
-
}
|
202
|
-
|