sidekick-client 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/sidekick/client/sidekick_client.rb +0 -3
- data/lib/sidekick/shared/sidekick_queue_publisher.rb +1 -1
- data/sidekick-client.gemspec +1 -158
- metadata +1 -158
- data/lib/ext/eventmachine-0.12.10/.gitignore +0 -14
- data/lib/ext/eventmachine-0.12.10/README +0 -82
- data/lib/ext/eventmachine-0.12.10/Rakefile +0 -374
- data/lib/ext/eventmachine-0.12.10/docs/COPYING +0 -60
- data/lib/ext/eventmachine-0.12.10/docs/ChangeLog +0 -211
- data/lib/ext/eventmachine-0.12.10/docs/DEFERRABLES +0 -133
- data/lib/ext/eventmachine-0.12.10/docs/EPOLL +0 -141
- data/lib/ext/eventmachine-0.12.10/docs/GNU +0 -281
- data/lib/ext/eventmachine-0.12.10/docs/INSTALL +0 -13
- data/lib/ext/eventmachine-0.12.10/docs/KEYBOARD +0 -38
- data/lib/ext/eventmachine-0.12.10/docs/LEGAL +0 -25
- data/lib/ext/eventmachine-0.12.10/docs/LIGHTWEIGHT_CONCURRENCY +0 -70
- data/lib/ext/eventmachine-0.12.10/docs/PURE_RUBY +0 -75
- data/lib/ext/eventmachine-0.12.10/docs/RELEASE_NOTES +0 -94
- data/lib/ext/eventmachine-0.12.10/docs/SMTP +0 -2
- data/lib/ext/eventmachine-0.12.10/docs/SPAWNED_PROCESSES +0 -89
- data/lib/ext/eventmachine-0.12.10/docs/TODO +0 -8
- data/lib/ext/eventmachine-0.12.10/eventmachine.gemspec +0 -40
- data/lib/ext/eventmachine-0.12.10/examples/ex_channel.rb +0 -43
- data/lib/ext/eventmachine-0.12.10/examples/ex_queue.rb +0 -2
- data/lib/ext/eventmachine-0.12.10/examples/helper.rb +0 -2
- data/lib/ext/eventmachine-0.12.10/ext/binder.cpp +0 -125
- data/lib/ext/eventmachine-0.12.10/ext/binder.h +0 -46
- data/lib/ext/eventmachine-0.12.10/ext/cmain.cpp +0 -827
- data/lib/ext/eventmachine-0.12.10/ext/cplusplus.cpp +0 -202
- data/lib/ext/eventmachine-0.12.10/ext/ed.cpp +0 -1893
- data/lib/ext/eventmachine-0.12.10/ext/ed.h +0 -424
- data/lib/ext/eventmachine-0.12.10/ext/em.cpp +0 -2282
- data/lib/ext/eventmachine-0.12.10/ext/em.h +0 -232
- data/lib/ext/eventmachine-0.12.10/ext/emwin.cpp +0 -300
- data/lib/ext/eventmachine-0.12.10/ext/emwin.h +0 -94
- data/lib/ext/eventmachine-0.12.10/ext/epoll.cpp +0 -26
- data/lib/ext/eventmachine-0.12.10/ext/epoll.h +0 -25
- data/lib/ext/eventmachine-0.12.10/ext/eventmachine.h +0 -122
- data/lib/ext/eventmachine-0.12.10/ext/eventmachine_cpp.h +0 -96
- data/lib/ext/eventmachine-0.12.10/ext/extconf.rb +0 -148
- data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/extconf.rb +0 -83
- data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/mapper.cpp +0 -214
- data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/mapper.h +0 -59
- data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/rubymain.cpp +0 -127
- data/lib/ext/eventmachine-0.12.10/ext/files.cpp +0 -94
- data/lib/ext/eventmachine-0.12.10/ext/files.h +0 -65
- data/lib/ext/eventmachine-0.12.10/ext/kb.cpp +0 -81
- data/lib/ext/eventmachine-0.12.10/ext/page.cpp +0 -107
- data/lib/ext/eventmachine-0.12.10/ext/page.h +0 -51
- data/lib/ext/eventmachine-0.12.10/ext/pipe.cpp +0 -349
- data/lib/ext/eventmachine-0.12.10/ext/project.h +0 -151
- data/lib/ext/eventmachine-0.12.10/ext/rubymain.cpp +0 -1166
- data/lib/ext/eventmachine-0.12.10/ext/sigs.cpp +0 -89
- data/lib/ext/eventmachine-0.12.10/ext/sigs.h +0 -32
- data/lib/ext/eventmachine-0.12.10/ext/ssl.cpp +0 -460
- data/lib/ext/eventmachine-0.12.10/ext/ssl.h +0 -94
- data/lib/ext/eventmachine-0.12.10/java/.classpath +0 -8
- data/lib/ext/eventmachine-0.12.10/java/.project +0 -17
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EmReactor.java +0 -570
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EmReactorException.java +0 -40
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableChannel.java +0 -69
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableDatagramChannel.java +0 -189
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableSocketChannel.java +0 -364
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Application.java +0 -194
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Connection.java +0 -74
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/ConnectionFactory.java +0 -37
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java +0 -46
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/PeriodicTimer.java +0 -38
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Timer.java +0 -54
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/ApplicationTest.java +0 -109
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/ConnectTest.java +0 -148
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/EMTest.java +0 -80
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestDatagrams.java +0 -53
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestServers.java +0 -75
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestTimers.java +0 -90
- data/lib/ext/eventmachine-0.12.10/lib/em/buftok.rb +0 -138
- data/lib/ext/eventmachine-0.12.10/lib/em/callback.rb +0 -26
- data/lib/ext/eventmachine-0.12.10/lib/em/channel.rb +0 -57
- data/lib/ext/eventmachine-0.12.10/lib/em/connection.rb +0 -564
- data/lib/ext/eventmachine-0.12.10/lib/em/deferrable.rb +0 -192
- data/lib/ext/eventmachine-0.12.10/lib/em/file_watch.rb +0 -54
- data/lib/ext/eventmachine-0.12.10/lib/em/future.rb +0 -61
- data/lib/ext/eventmachine-0.12.10/lib/em/messages.rb +0 -66
- data/lib/ext/eventmachine-0.12.10/lib/em/process_watch.rb +0 -44
- data/lib/ext/eventmachine-0.12.10/lib/em/processes.rb +0 -119
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/header_and_content.rb +0 -138
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/httpclient.rb +0 -263
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/httpclient2.rb +0 -590
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/line_and_text.rb +0 -125
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/linetext2.rb +0 -161
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/memcache.rb +0 -323
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/object_protocol.rb +0 -45
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/postgres3.rb +0 -247
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/saslauth.rb +0 -175
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/smtpclient.rb +0 -357
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/smtpserver.rb +0 -547
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/socks4.rb +0 -66
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/stomp.rb +0 -200
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/tcptest.rb +0 -53
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols.rb +0 -36
- data/lib/ext/eventmachine-0.12.10/lib/em/queue.rb +0 -61
- data/lib/ext/eventmachine-0.12.10/lib/em/spawnable.rb +0 -85
- data/lib/ext/eventmachine-0.12.10/lib/em/streamer.rb +0 -130
- data/lib/ext/eventmachine-0.12.10/lib/em/timers.rb +0 -56
- data/lib/ext/eventmachine-0.12.10/lib/em/version.rb +0 -3
- data/lib/ext/eventmachine-0.12.10/lib/eventmachine.rb +0 -1592
- data/lib/ext/eventmachine-0.12.10/lib/evma/callback.rb +0 -32
- data/lib/ext/eventmachine-0.12.10/lib/evma/container.rb +0 -75
- data/lib/ext/eventmachine-0.12.10/lib/evma/factory.rb +0 -77
- data/lib/ext/eventmachine-0.12.10/lib/evma/protocol.rb +0 -87
- data/lib/ext/eventmachine-0.12.10/lib/evma/reactor.rb +0 -48
- data/lib/ext/eventmachine-0.12.10/lib/evma.rb +0 -32
- data/lib/ext/eventmachine-0.12.10/lib/jeventmachine.rb +0 -257
- data/lib/ext/eventmachine-0.12.10/lib/pr_eventmachine.rb +0 -1022
- data/lib/ext/eventmachine-0.12.10/setup.rb +0 -1585
- data/lib/ext/eventmachine-0.12.10/tasks/cpp.rake_example +0 -77
- data/lib/ext/eventmachine-0.12.10/tests/client.crt +0 -31
- data/lib/ext/eventmachine-0.12.10/tests/client.key +0 -51
- data/lib/ext/eventmachine-0.12.10/tests/test_attach.rb +0 -126
- data/lib/ext/eventmachine-0.12.10/tests/test_basic.rb +0 -284
- data/lib/ext/eventmachine-0.12.10/tests/test_channel.rb +0 -63
- data/lib/ext/eventmachine-0.12.10/tests/test_connection_count.rb +0 -35
- data/lib/ext/eventmachine-0.12.10/tests/test_defer.rb +0 -47
- data/lib/ext/eventmachine-0.12.10/tests/test_epoll.rb +0 -160
- data/lib/ext/eventmachine-0.12.10/tests/test_error_handler.rb +0 -35
- data/lib/ext/eventmachine-0.12.10/tests/test_errors.rb +0 -82
- data/lib/ext/eventmachine-0.12.10/tests/test_exc.rb +0 -55
- data/lib/ext/eventmachine-0.12.10/tests/test_file_watch.rb +0 -49
- data/lib/ext/eventmachine-0.12.10/tests/test_futures.rb +0 -198
- data/lib/ext/eventmachine-0.12.10/tests/test_get_sock_opt.rb +0 -30
- data/lib/ext/eventmachine-0.12.10/tests/test_handler_check.rb +0 -37
- data/lib/ext/eventmachine-0.12.10/tests/test_hc.rb +0 -218
- data/lib/ext/eventmachine-0.12.10/tests/test_httpclient.rb +0 -218
- data/lib/ext/eventmachine-0.12.10/tests/test_httpclient2.rb +0 -153
- data/lib/ext/eventmachine-0.12.10/tests/test_inactivity_timeout.rb +0 -50
- data/lib/ext/eventmachine-0.12.10/tests/test_kb.rb +0 -60
- data/lib/ext/eventmachine-0.12.10/tests/test_ltp.rb +0 -182
- data/lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb +0 -317
- data/lib/ext/eventmachine-0.12.10/tests/test_next_tick.rb +0 -133
- data/lib/ext/eventmachine-0.12.10/tests/test_object_protocol.rb +0 -37
- data/lib/ext/eventmachine-0.12.10/tests/test_pause.rb +0 -70
- data/lib/ext/eventmachine-0.12.10/tests/test_pending_connect_timeout.rb +0 -48
- data/lib/ext/eventmachine-0.12.10/tests/test_process_watch.rb +0 -48
- data/lib/ext/eventmachine-0.12.10/tests/test_processes.rb +0 -128
- data/lib/ext/eventmachine-0.12.10/tests/test_proxy_connection.rb +0 -92
- data/lib/ext/eventmachine-0.12.10/tests/test_pure.rb +0 -125
- data/lib/ext/eventmachine-0.12.10/tests/test_queue.rb +0 -44
- data/lib/ext/eventmachine-0.12.10/tests/test_running.rb +0 -42
- data/lib/ext/eventmachine-0.12.10/tests/test_sasl.rb +0 -72
- data/lib/ext/eventmachine-0.12.10/tests/test_send_file.rb +0 -242
- data/lib/ext/eventmachine-0.12.10/tests/test_servers.rb +0 -76
- data/lib/ext/eventmachine-0.12.10/tests/test_smtpclient.rb +0 -83
- data/lib/ext/eventmachine-0.12.10/tests/test_smtpserver.rb +0 -85
- data/lib/ext/eventmachine-0.12.10/tests/test_spawn.rb +0 -322
- data/lib/ext/eventmachine-0.12.10/tests/test_ssl_args.rb +0 -79
- data/lib/ext/eventmachine-0.12.10/tests/test_ssl_methods.rb +0 -50
- data/lib/ext/eventmachine-0.12.10/tests/test_ssl_verify.rb +0 -82
- data/lib/ext/eventmachine-0.12.10/tests/test_timers.rb +0 -162
- data/lib/ext/eventmachine-0.12.10/tests/test_ud.rb +0 -36
- data/lib/ext/eventmachine-0.12.10/tests/testem.rb +0 -31
- data/lib/ext/eventmachine-0.12.10/web/whatis +0 -7
@@ -1,80 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* $Id$
|
3
|
-
*
|
4
|
-
* Author:: Francis Cianfrocca (gmail: blackhedd)
|
5
|
-
* Homepage:: http://rubyeventmachine.com
|
6
|
-
* Date:: 15 Jul 2007
|
7
|
-
*
|
8
|
-
* See EventMachine and EventMachine::Connection for documentation and
|
9
|
-
* usage examples.
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*----------------------------------------------------------------------------
|
13
|
-
*
|
14
|
-
* Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
15
|
-
* Gmail: blackhedd
|
16
|
-
*
|
17
|
-
* This program is free software; you can redistribute it and/or modify
|
18
|
-
* it under the terms of either: 1) the GNU General Public License
|
19
|
-
* as published by the Free Software Foundation; either version 2 of the
|
20
|
-
* License, or (at your option) any later version; or 2) Ruby's License.
|
21
|
-
*
|
22
|
-
* See the file COPYING for complete licensing information.
|
23
|
-
*
|
24
|
-
*---------------------------------------------------------------------------
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*/
|
28
|
-
|
29
|
-
|
30
|
-
package com.rubyeventmachine.tests;
|
31
|
-
|
32
|
-
//import static org.junit.Assert.*;
|
33
|
-
|
34
|
-
import org.junit.After;
|
35
|
-
import org.junit.AfterClass;
|
36
|
-
import org.junit.Before;
|
37
|
-
import org.junit.BeforeClass;
|
38
|
-
import org.junit.Test;
|
39
|
-
|
40
|
-
import com.rubyeventmachine.EmReactor;
|
41
|
-
|
42
|
-
import java.io.*;
|
43
|
-
import java.nio.*;
|
44
|
-
|
45
|
-
|
46
|
-
public class EMTest {
|
47
|
-
|
48
|
-
class ShortTimer extends EmReactor {
|
49
|
-
public void eventCallback (String sig, int eventCode, ByteBuffer data) {
|
50
|
-
System.out.println ("Short Callback "+sig+" "+eventCode+" "+data);
|
51
|
-
this.stop();
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
@BeforeClass
|
56
|
-
public static void setUpBeforeClass() throws Exception {
|
57
|
-
}
|
58
|
-
|
59
|
-
@AfterClass
|
60
|
-
public static void tearDownAfterClass() throws Exception {
|
61
|
-
}
|
62
|
-
|
63
|
-
@Before
|
64
|
-
public void setUp() throws Exception {
|
65
|
-
}
|
66
|
-
|
67
|
-
@After
|
68
|
-
public void tearDown() throws Exception {
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
@Test
|
73
|
-
public final void testOneShort() throws IOException {
|
74
|
-
EmReactor em = new ShortTimer();
|
75
|
-
em.installOneshotTimer(1050);
|
76
|
-
em.run();
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
}
|
@@ -1,53 +0,0 @@
|
|
1
|
-
package com.rubyeventmachine.tests;
|
2
|
-
|
3
|
-
import com.rubyeventmachine.application.*;
|
4
|
-
import java.net.*;
|
5
|
-
import java.nio.*;
|
6
|
-
|
7
|
-
import org.junit.After;
|
8
|
-
import org.junit.AfterClass;
|
9
|
-
import org.junit.Before;
|
10
|
-
import org.junit.BeforeClass;
|
11
|
-
import org.junit.Test;
|
12
|
-
|
13
|
-
|
14
|
-
public class TestDatagrams {
|
15
|
-
|
16
|
-
@BeforeClass
|
17
|
-
public static void setUpBeforeClass() throws Exception {
|
18
|
-
}
|
19
|
-
|
20
|
-
@AfterClass
|
21
|
-
public static void tearDownAfterClass() throws Exception {
|
22
|
-
}
|
23
|
-
|
24
|
-
@Before
|
25
|
-
public void setUp() throws Exception {
|
26
|
-
}
|
27
|
-
|
28
|
-
@After
|
29
|
-
public void tearDown() throws Exception {
|
30
|
-
}
|
31
|
-
|
32
|
-
class A extends Connection {
|
33
|
-
public void receiveData (ByteBuffer bb) {
|
34
|
-
application.stop();
|
35
|
-
}
|
36
|
-
}
|
37
|
-
class B extends Connection {
|
38
|
-
public void postInit() {
|
39
|
-
this.sendDatagram(ByteBuffer.wrap(new String("ABC").getBytes()), new InetSocketAddress ("127.0.0.1", 9550));
|
40
|
-
}
|
41
|
-
|
42
|
-
}
|
43
|
-
@Test
|
44
|
-
public final void testA() {
|
45
|
-
final Application a = new Application();
|
46
|
-
a.run (new Runnable() {
|
47
|
-
public void run() {
|
48
|
-
a.openDatagramSocket( new InetSocketAddress ("0.0.0.0", 9550), new A() );
|
49
|
-
a.openDatagramSocket( new B() );
|
50
|
-
}
|
51
|
-
});
|
52
|
-
}
|
53
|
-
}
|
@@ -1,75 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* $Id$
|
3
|
-
*
|
4
|
-
* Author:: Francis Cianfrocca (gmail: blackhedd)
|
5
|
-
* Homepage:: http://rubyeventmachine.com
|
6
|
-
* Date:: 15 Jul 2007
|
7
|
-
*
|
8
|
-
* See EventMachine and EventMachine::Connection for documentation and
|
9
|
-
* usage examples.
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*----------------------------------------------------------------------------
|
13
|
-
*
|
14
|
-
* Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
15
|
-
* Gmail: blackhedd
|
16
|
-
*
|
17
|
-
* This program is free software; you can redistribute it and/or modify
|
18
|
-
* it under the terms of either: 1) the GNU General Public License
|
19
|
-
* as published by the Free Software Foundation; either version 2 of the
|
20
|
-
* License, or (at your option) any later version; or 2) Ruby's License.
|
21
|
-
*
|
22
|
-
* See the file COPYING for complete licensing information.
|
23
|
-
*
|
24
|
-
*---------------------------------------------------------------------------
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*/
|
28
|
-
|
29
|
-
|
30
|
-
package com.rubyeventmachine.tests;
|
31
|
-
|
32
|
-
|
33
|
-
import com.rubyeventmachine.*;
|
34
|
-
import com.rubyeventmachine.application.*;
|
35
|
-
import java.net.*;
|
36
|
-
import org.junit.After;
|
37
|
-
import org.junit.AfterClass;
|
38
|
-
import org.junit.Before;
|
39
|
-
import org.junit.BeforeClass;
|
40
|
-
import org.junit.Test;
|
41
|
-
import org.junit.Assert;
|
42
|
-
|
43
|
-
public class TestServers {
|
44
|
-
|
45
|
-
@BeforeClass
|
46
|
-
public static void setUpBeforeClass() throws Exception {
|
47
|
-
}
|
48
|
-
|
49
|
-
@AfterClass
|
50
|
-
public static void tearDownAfterClass() throws Exception {
|
51
|
-
}
|
52
|
-
|
53
|
-
@Before
|
54
|
-
public void setUp() throws Exception {
|
55
|
-
}
|
56
|
-
|
57
|
-
@After
|
58
|
-
public void tearDown() throws Exception {
|
59
|
-
}
|
60
|
-
|
61
|
-
|
62
|
-
@Test
|
63
|
-
public void testBadServerAddress() {
|
64
|
-
final Application a = new Application();
|
65
|
-
a.run (new Runnable() {
|
66
|
-
public void run() {
|
67
|
-
try {
|
68
|
-
a.startServer(new InetSocketAddress ("100.100.100.100", 100), new DefaultConnectionFactory());
|
69
|
-
Assert.fail ("was supposed to throw a reactor exception");
|
70
|
-
} catch (EmReactorException e) {}
|
71
|
-
a.stop();
|
72
|
-
}
|
73
|
-
});
|
74
|
-
}
|
75
|
-
}
|
@@ -1,90 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* $Id$
|
3
|
-
*
|
4
|
-
* Author:: Francis Cianfrocca (gmail: blackhedd)
|
5
|
-
* Homepage:: http://rubyeventmachine.com
|
6
|
-
* Date:: 15 Jul 2007
|
7
|
-
*
|
8
|
-
* See EventMachine and EventMachine::Connection for documentation and
|
9
|
-
* usage examples.
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*----------------------------------------------------------------------------
|
13
|
-
*
|
14
|
-
* Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
15
|
-
* Gmail: blackhedd
|
16
|
-
*
|
17
|
-
* This program is free software; you can redistribute it and/or modify
|
18
|
-
* it under the terms of either: 1) the GNU General Public License
|
19
|
-
* as published by the Free Software Foundation; either version 2 of the
|
20
|
-
* License, or (at your option) any later version; or 2) Ruby's License.
|
21
|
-
*
|
22
|
-
* See the file COPYING for complete licensing information.
|
23
|
-
*
|
24
|
-
*---------------------------------------------------------------------------
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*/
|
28
|
-
|
29
|
-
|
30
|
-
package com.rubyeventmachine.tests;
|
31
|
-
|
32
|
-
import com.rubyeventmachine.*;
|
33
|
-
import com.rubyeventmachine.application.*;
|
34
|
-
import java.io.*;
|
35
|
-
|
36
|
-
import org.junit.Assert;
|
37
|
-
import org.junit.After;
|
38
|
-
import org.junit.AfterClass;
|
39
|
-
import org.junit.Before;
|
40
|
-
import org.junit.BeforeClass;
|
41
|
-
import org.junit.Test;
|
42
|
-
|
43
|
-
|
44
|
-
public class TestTimers {
|
45
|
-
|
46
|
-
@BeforeClass
|
47
|
-
public static void setUpBeforeClass() throws Exception {
|
48
|
-
}
|
49
|
-
|
50
|
-
@AfterClass
|
51
|
-
public static void tearDownAfterClass() throws Exception {
|
52
|
-
}
|
53
|
-
|
54
|
-
@Before
|
55
|
-
public void setUp() throws Exception {
|
56
|
-
}
|
57
|
-
|
58
|
-
@After
|
59
|
-
public void tearDown() throws Exception {
|
60
|
-
}
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
@Test
|
65
|
-
public final void test2() throws IOException {
|
66
|
-
Application a = new Application();
|
67
|
-
a.addTimer(0, new Timer() {
|
68
|
-
public void fire() {
|
69
|
-
application.stop();
|
70
|
-
}
|
71
|
-
});
|
72
|
-
a.run();
|
73
|
-
Assert.assertEquals (1, 1); // just to make sure the reactor halts.
|
74
|
-
}
|
75
|
-
|
76
|
-
@Test
|
77
|
-
public final void test3() throws IOException {
|
78
|
-
Application a = new Application();
|
79
|
-
a.addTimer (0.1, new PeriodicTimer() {
|
80
|
-
int n = 0;
|
81
|
-
public void fire() {
|
82
|
-
n++;
|
83
|
-
if (n == 5)
|
84
|
-
application.stop();
|
85
|
-
}
|
86
|
-
});
|
87
|
-
a.run();
|
88
|
-
Assert.assertEquals(1, 1);
|
89
|
-
}
|
90
|
-
}
|
@@ -1,138 +0,0 @@
|
|
1
|
-
# BufferedTokenizer - Statefully split input data by a specifiable token
|
2
|
-
#
|
3
|
-
# Authors:: Tony Arcieri, Martin Emde
|
4
|
-
#
|
5
|
-
#----------------------------------------------------------------------------
|
6
|
-
#
|
7
|
-
# Copyright (C) 2006-07 by Tony Arcieri and Martin Emde
|
8
|
-
#
|
9
|
-
# Distributed under the Ruby license (http://www.ruby-lang.org/en/LICENSE.txt)
|
10
|
-
#
|
11
|
-
#---------------------------------------------------------------------------
|
12
|
-
#
|
13
|
-
|
14
|
-
# (C)2006 Tony Arcieri, Martin Emde
|
15
|
-
# Distributed under the Ruby license (http://www.ruby-lang.org/en/LICENSE.txt)
|
16
|
-
|
17
|
-
# BufferedTokenizer takes a delimiter upon instantiation, or acts line-based
|
18
|
-
# by default. It allows input to be spoon-fed from some outside source which
|
19
|
-
# receives arbitrary length datagrams which may-or-may-not contain the token
|
20
|
-
# by which entities are delimited.
|
21
|
-
#
|
22
|
-
# Commonly used to parse lines out of incoming data:
|
23
|
-
#
|
24
|
-
# module LineBufferedConnection
|
25
|
-
# def receive_data(data)
|
26
|
-
# (@buffer ||= BufferedTokenizer.new).extract(data).each do |line|
|
27
|
-
# receive_line(line)
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
# end
|
31
|
-
|
32
|
-
class BufferedTokenizer
|
33
|
-
# New BufferedTokenizers will operate on lines delimited by "\n" by default
|
34
|
-
# or allow you to specify any delimiter token you so choose, which will then
|
35
|
-
# be used by String#split to tokenize the input data
|
36
|
-
def initialize(delimiter = "\n", size_limit = nil)
|
37
|
-
# Store the specified delimiter
|
38
|
-
@delimiter = delimiter
|
39
|
-
|
40
|
-
# Store the specified size limitation
|
41
|
-
@size_limit = size_limit
|
42
|
-
|
43
|
-
# The input buffer is stored as an array. This is by far the most efficient
|
44
|
-
# approach given language constraints (in C a linked list would be a more
|
45
|
-
# appropriate data structure). Segments of input data are stored in a list
|
46
|
-
# which is only joined when a token is reached, substantially reducing the
|
47
|
-
# number of objects required for the operation.
|
48
|
-
@input = []
|
49
|
-
|
50
|
-
# Size of the input buffer
|
51
|
-
@input_size = 0
|
52
|
-
end
|
53
|
-
|
54
|
-
# Extract takes an arbitrary string of input data and returns an array of
|
55
|
-
# tokenized entities, provided there were any available to extract. This
|
56
|
-
# makes for easy processing of datagrams using a pattern like:
|
57
|
-
#
|
58
|
-
# tokenizer.extract(data).map { |entity| Decode(entity) }.each do ...
|
59
|
-
def extract(data)
|
60
|
-
# Extract token-delimited entities from the input string with the split command.
|
61
|
-
# There's a bit of craftiness here with the -1 parameter. Normally split would
|
62
|
-
# behave no differently regardless of if the token lies at the very end of the
|
63
|
-
# input buffer or not (i.e. a literal edge case) Specifying -1 forces split to
|
64
|
-
# return "" in this case, meaning that the last entry in the list represents a
|
65
|
-
# new segment of data where the token has not been encountered
|
66
|
-
entities = data.split @delimiter, -1
|
67
|
-
|
68
|
-
# Check to see if the buffer has exceeded capacity, if we're imposing a limit
|
69
|
-
if @size_limit
|
70
|
-
raise 'input buffer full' if @input_size + entities.first.size > @size_limit
|
71
|
-
@input_size += entities.first.size
|
72
|
-
end
|
73
|
-
|
74
|
-
# Move the first entry in the resulting array into the input buffer. It represents
|
75
|
-
# the last segment of a token-delimited entity unless it's the only entry in the list.
|
76
|
-
@input << entities.shift
|
77
|
-
|
78
|
-
# If the resulting array from the split is empty, the token was not encountered
|
79
|
-
# (not even at the end of the buffer). Since we've encountered no token-delimited
|
80
|
-
# entities this go-around, return an empty array.
|
81
|
-
return [] if entities.empty?
|
82
|
-
|
83
|
-
# At this point, we've hit a token, or potentially multiple tokens. Now we can bring
|
84
|
-
# together all the data we've buffered from earlier calls without hitting a token,
|
85
|
-
# and add it to our list of discovered entities.
|
86
|
-
entities.unshift @input.join
|
87
|
-
|
88
|
-
=begin
|
89
|
-
# Note added by FC, 10Jul07. This paragraph contains a regression. It breaks
|
90
|
-
# empty tokens. Think of the empty line that delimits an HTTP header. It will have
|
91
|
-
# two "\n" delimiters in a row, and this code mishandles the resulting empty token.
|
92
|
-
# It someone figures out how to fix the problem, we can re-enable this code branch.
|
93
|
-
# Multi-character token support.
|
94
|
-
# Split any tokens that were incomplete on the last iteration buf complete now.
|
95
|
-
entities.map! do |e|
|
96
|
-
e.split @delimiter, -1
|
97
|
-
end
|
98
|
-
# Flatten the resulting array. This has the side effect of removing the empty
|
99
|
-
# entry at the end that was produced by passing -1 to split. Add it again if
|
100
|
-
# necessary.
|
101
|
-
if (entities[-1] == [])
|
102
|
-
entities.flatten! << []
|
103
|
-
else
|
104
|
-
entities.flatten!
|
105
|
-
end
|
106
|
-
=end
|
107
|
-
|
108
|
-
# Now that we've hit a token, joined the input buffer and added it to the entities
|
109
|
-
# list, we can go ahead and clear the input buffer. All of the segments that were
|
110
|
-
# stored before the join can now be garbage collected.
|
111
|
-
@input.clear
|
112
|
-
|
113
|
-
# The last entity in the list is not token delimited, however, thanks to the -1
|
114
|
-
# passed to split. It represents the beginning of a new list of as-yet-untokenized
|
115
|
-
# data, so we add it to the start of the list.
|
116
|
-
@input << entities.pop
|
117
|
-
|
118
|
-
# Set the new input buffer size, provided we're keeping track
|
119
|
-
@input_size = @input.first.size if @size_limit
|
120
|
-
|
121
|
-
# Now we're left with the list of extracted token-delimited entities we wanted
|
122
|
-
# in the first place. Hooray!
|
123
|
-
entities
|
124
|
-
end
|
125
|
-
|
126
|
-
# Flush the contents of the input buffer, i.e. return the input buffer even though
|
127
|
-
# a token has not yet been encountered
|
128
|
-
def flush
|
129
|
-
buffer = @input.join
|
130
|
-
@input.clear
|
131
|
-
buffer
|
132
|
-
end
|
133
|
-
|
134
|
-
# Is the buffer empty?
|
135
|
-
def empty?
|
136
|
-
@input.empty?
|
137
|
-
end
|
138
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module EventMachine
|
2
|
-
# Utility method for coercing arguments to an object that responds to #call
|
3
|
-
# Accepts an object and a method name to send to, or a block, or an object
|
4
|
-
# that responds to call.
|
5
|
-
#
|
6
|
-
# cb = EM.Callback{ |msg| puts(msg) }
|
7
|
-
# cb.call('hello world')
|
8
|
-
#
|
9
|
-
# cb = EM.Callback(Object, :puts)
|
10
|
-
# cb.call('hello world')
|
11
|
-
#
|
12
|
-
# cb = EM.Callback(proc{ |msg| puts(msg) })
|
13
|
-
# cb.call('hello world')
|
14
|
-
#
|
15
|
-
def self.Callback(object = nil, method = nil, &blk)
|
16
|
-
if object && method
|
17
|
-
lambda { |*args| object.send method, *args }
|
18
|
-
else
|
19
|
-
if object.respond_to? :call
|
20
|
-
object
|
21
|
-
else
|
22
|
-
blk || raise(ArgumentError)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
module EventMachine
|
2
|
-
# Provides a simple interface to push items to a number of subscribers. The
|
3
|
-
# channel will schedule all operations on the main reactor thread for thread
|
4
|
-
# safe reactor operations.
|
5
|
-
#
|
6
|
-
# This provides a convenient way for connections to consume messages from
|
7
|
-
# long running code in defer, without threading issues.
|
8
|
-
#
|
9
|
-
# channel = EM::Channel.new
|
10
|
-
# sid = channel.subscribe{ |msg| p [:got, msg] }
|
11
|
-
# channel.push('hello world')
|
12
|
-
# channel.unsubscribe(sid)
|
13
|
-
#
|
14
|
-
# See examples/ex_channel.rb for a detailed example.
|
15
|
-
class Channel
|
16
|
-
# Create a new channel
|
17
|
-
def initialize
|
18
|
-
@subs = {}
|
19
|
-
@uid = 0
|
20
|
-
end
|
21
|
-
|
22
|
-
# Takes any arguments suitable for EM::Callback() and returns a subscriber
|
23
|
-
# id for use when unsubscribing.
|
24
|
-
def subscribe(*a, &b)
|
25
|
-
name = gen_id
|
26
|
-
EM.schedule { @subs[name] = EM::Callback(*a, &b) }
|
27
|
-
name
|
28
|
-
end
|
29
|
-
|
30
|
-
# Removes this subscriber from the list.
|
31
|
-
def unsubscribe(name)
|
32
|
-
EM.schedule { @subs.delete name }
|
33
|
-
end
|
34
|
-
|
35
|
-
# Add items to the channel, which are pushed out to all subscribers.
|
36
|
-
def push(*items)
|
37
|
-
items = items.dup
|
38
|
-
EM.schedule { @subs.values.each { |s| items.each { |i| s.call i } } }
|
39
|
-
end
|
40
|
-
alias << push
|
41
|
-
|
42
|
-
# Receive exactly one message from the channel.
|
43
|
-
def pop(*a, &b)
|
44
|
-
EM.schedule {
|
45
|
-
name = subscribe do |*args|
|
46
|
-
unsubscribe(name)
|
47
|
-
EM::Callback(*a, &b).call(*args)
|
48
|
-
end
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
def gen_id # :nodoc:
|
54
|
-
@uid += 1
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|