eventmachine 0.12.2 → 0.12.4

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.
Files changed (125) hide show
  1. data/Rakefile +191 -0
  2. data/{COPYING → docs/COPYING} +0 -0
  3. data/docs/ChangeLog +183 -0
  4. data/{DEFERRABLES → docs/DEFERRABLES} +1 -1
  5. data/{EPOLL → docs/EPOLL} +0 -0
  6. data/{GNU → docs/GNU} +0 -0
  7. data/docs/INSTALL +15 -0
  8. data/{KEYBOARD → docs/KEYBOARD} +0 -0
  9. data/{LEGAL → docs/LEGAL} +0 -0
  10. data/{LIGHTWEIGHT_CONCURRENCY → docs/LIGHTWEIGHT_CONCURRENCY} +1 -1
  11. data/{PURE_RUBY → docs/PURE_RUBY} +1 -1
  12. data/{README → docs/README} +1 -1
  13. data/{RELEASE_NOTES → docs/RELEASE_NOTES} +1 -1
  14. data/{SMTP → docs/SMTP} +1 -1
  15. data/{SPAWNED_PROCESSES → docs/SPAWNED_PROCESSES} +1 -1
  16. data/{TODO → docs/TODO} +1 -1
  17. data/ext/binder.cpp +1 -1
  18. data/ext/binder.h +1 -1
  19. data/ext/cmain.cpp +65 -74
  20. data/ext/cplusplus.cpp +1 -1
  21. data/ext/ed.cpp +41 -25
  22. data/ext/ed.h +10 -3
  23. data/ext/em.cpp +39 -12
  24. data/ext/em.h +13 -1
  25. data/ext/emwin.cpp +1 -1
  26. data/ext/emwin.h +1 -1
  27. data/ext/epoll.cpp +1 -1
  28. data/ext/epoll.h +1 -1
  29. data/ext/eventmachine.h +1 -1
  30. data/ext/eventmachine_cpp.h +1 -1
  31. data/ext/extconf.rb +86 -139
  32. data/ext/fastfilereader/extconf.rb +161 -0
  33. data/ext/fastfilereader/mapper.cpp +202 -0
  34. data/ext/fastfilereader/mapper.h +59 -0
  35. data/ext/fastfilereader/rubymain.cpp +127 -0
  36. data/ext/files.cpp +1 -1
  37. data/ext/files.h +1 -1
  38. data/ext/kb.cpp +1 -1
  39. data/ext/page.cpp +1 -1
  40. data/ext/page.h +1 -1
  41. data/ext/pipe.cpp +14 -7
  42. data/ext/project.h +1 -1
  43. data/ext/rubymain.cpp +56 -2
  44. data/ext/sigs.cpp +1 -1
  45. data/ext/sigs.h +1 -1
  46. data/ext/ssl.cpp +1 -1
  47. data/ext/ssl.h +1 -1
  48. data/java/src/com/rubyeventmachine/Application.java +196 -0
  49. data/java/src/com/rubyeventmachine/Connection.java +74 -0
  50. data/java/src/com/rubyeventmachine/ConnectionFactory.java +37 -0
  51. data/java/src/com/rubyeventmachine/DefaultConnectionFactory.java +46 -0
  52. data/java/src/com/rubyeventmachine/EmReactor.java +408 -0
  53. data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
  54. data/java/src/com/rubyeventmachine/EventableChannel.java +57 -0
  55. data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +171 -0
  56. data/java/src/com/rubyeventmachine/EventableSocketChannel.java +244 -0
  57. data/java/src/com/rubyeventmachine/PeriodicTimer.java +38 -0
  58. data/java/src/com/rubyeventmachine/Timer.java +54 -0
  59. data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +108 -0
  60. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +124 -0
  61. data/java/src/com/rubyeventmachine/tests/EMTest.java +80 -0
  62. data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -0
  63. data/java/src/com/rubyeventmachine/tests/TestServers.java +74 -0
  64. data/java/src/com/rubyeventmachine/tests/TestTimers.java +89 -0
  65. data/lib/em/deferrable.rb +1 -1
  66. data/lib/em/eventable.rb +1 -1
  67. data/lib/em/future.rb +1 -1
  68. data/lib/em/messages.rb +1 -1
  69. data/lib/em/processes.rb +1 -1
  70. data/lib/em/spawnable.rb +1 -1
  71. data/lib/em/streamer.rb +1 -1
  72. data/lib/eventmachine.rb +138 -116
  73. data/lib/eventmachine_version.rb +2 -2
  74. data/lib/evma.rb +1 -1
  75. data/lib/evma/callback.rb +1 -1
  76. data/lib/evma/container.rb +1 -1
  77. data/lib/evma/factory.rb +1 -1
  78. data/lib/evma/protocol.rb +1 -1
  79. data/lib/evma/reactor.rb +1 -1
  80. data/lib/jeventmachine.rb +7 -2
  81. data/lib/pr_eventmachine.rb +2 -2
  82. data/lib/protocols/buftok.rb +1 -1
  83. data/lib/protocols/header_and_content.rb +1 -1
  84. data/lib/protocols/httpcli2.rb +16 -6
  85. data/lib/protocols/httpclient.rb +7 -1
  86. data/lib/protocols/line_and_text.rb +6 -2
  87. data/lib/protocols/linetext2.rb +12 -14
  88. data/lib/protocols/postgres.rb +1 -1
  89. data/lib/protocols/saslauth.rb +1 -1
  90. data/lib/protocols/smtpclient.rb +1 -1
  91. data/lib/protocols/smtpserver.rb +36 -23
  92. data/lib/protocols/stomp.rb +24 -1
  93. data/lib/protocols/tcptest.rb +1 -1
  94. data/tasks/cpp.rake +77 -0
  95. data/tasks/project.rake +78 -0
  96. data/tasks/tests.rake +192 -0
  97. data/tests/test_attach.rb +1 -1
  98. data/tests/test_basic.rb +65 -12
  99. data/tests/test_defer.rb +13 -29
  100. data/tests/test_epoll.rb +16 -21
  101. data/tests/test_errors.rb +1 -1
  102. data/tests/test_eventables.rb +4 -5
  103. data/tests/test_exc.rb +1 -1
  104. data/tests/test_futures.rb +1 -1
  105. data/tests/test_hc.rb +185 -236
  106. data/tests/test_httpclient.rb +1 -1
  107. data/tests/test_httpclient2.rb +28 -6
  108. data/tests/test_kb.rb +2 -2
  109. data/tests/test_ltp.rb +139 -141
  110. data/tests/test_ltp2.rb +1 -1
  111. data/tests/test_next_tick.rb +1 -1
  112. data/tests/test_processes.rb +1 -1
  113. data/tests/test_pure.rb +3 -2
  114. data/tests/test_running.rb +1 -1
  115. data/tests/test_sasl.rb +1 -1
  116. data/tests/test_send_file.rb +56 -51
  117. data/tests/test_servers.rb +26 -36
  118. data/tests/test_smtpclient.rb +46 -44
  119. data/tests/test_smtpserver.rb +1 -1
  120. data/tests/test_spawn.rb +1 -1
  121. data/tests/test_ssl_args.rb +68 -0
  122. data/tests/test_timers.rb +15 -9
  123. data/tests/test_ud.rb +1 -1
  124. data/tests/testem.rb +30 -4
  125. metadata +69 -34
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: files.cpp 668 2008-01-04 23:00:34Z blackhedd $
3
+ $Id$
4
4
 
5
5
  File: files.cpp
6
6
  Date: 26Aug06
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: files.h 668 2008-01-04 23:00:34Z blackhedd $
3
+ $Id$
4
4
 
5
5
  File: files.h
6
6
  Date: 26Aug06
data/ext/kb.cpp CHANGED
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: kb.cpp 668 2008-01-04 23:00:34Z blackhedd $
3
+ $Id$
4
4
 
5
5
  File: kb.cpp
6
6
  Date: 24Aug07
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: page.cpp 668 2008-01-04 23:00:34Z blackhedd $
3
+ $Id$
4
4
 
5
5
  File: page.cpp
6
6
  Date: 30Apr06
data/ext/page.h CHANGED
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: page.h 668 2008-01-04 23:00:34Z blackhedd $
3
+ $Id$
4
4
 
5
5
  File: page.h
6
6
  Date: 30Apr06
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: pipe.cpp 668 2008-01-04 23:00:34Z blackhedd $
3
+ $Id$
4
4
 
5
5
  File: pipe.cpp
6
6
  Date: 30May07
@@ -92,15 +92,22 @@ PipeDescriptor::~PipeDescriptor()
92
92
  * within other unbind calls. (Not sure if that's even possible.)
93
93
  */
94
94
 
95
- struct timespec req = {0, 10000000};
96
- kill (SubprocessPid, SIGTERM);
97
- nanosleep (&req, NULL);
98
95
  assert (MyEventMachine);
96
+
97
+ // check if the process is already dead
99
98
  if (waitpid (SubprocessPid, &(MyEventMachine->SubprocessExitStatus), WNOHANG) == 0) {
100
- kill (SubprocessPid, SIGKILL);
99
+ kill (SubprocessPid, SIGTERM);
100
+ // wait 0.25s for process to die
101
+ struct timespec req = {0, 250000000};
101
102
  nanosleep (&req, NULL);
102
- if (waitpid (SubprocessPid, &(MyEventMachine->SubprocessExitStatus), WNOHANG) == 0)
103
- throw std::runtime_error ("unable to reap subprocess");
103
+ if (waitpid (SubprocessPid, &(MyEventMachine->SubprocessExitStatus), WNOHANG) == 0) {
104
+ kill (SubprocessPid, SIGKILL);
105
+ // wait 0.5s for process to die
106
+ struct timespec req = {0, 500000000};
107
+ nanosleep (&req, NULL);
108
+ if (waitpid (SubprocessPid, &(MyEventMachine->SubprocessExitStatus), WNOHANG) == 0)
109
+ throw std::runtime_error ("unable to reap subprocess");
110
+ }
104
111
  }
105
112
  }
106
113
 
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: project.h 686 2008-05-14 21:21:10Z francis $
3
+ $Id$
4
4
 
5
5
  File: project.h
6
6
  Date: 06Apr06
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: rubymain.cpp 785 2008-09-15 09:46:23Z francis $
3
+ $Id$
4
4
 
5
5
  File: rubymain.cpp
6
6
  Date: 06Apr06
@@ -463,7 +463,12 @@ t_invoke_popen
463
463
 
464
464
  static VALUE t_invoke_popen (VALUE self, VALUE cmd)
465
465
  {
466
- int len = RARRAY (cmd)->len;
466
+ // 1.8.7+
467
+ #ifdef RARRAY_LEN
468
+ int len = RARRAY_LEN(cmd);
469
+ #else
470
+ int len = RARRAY (cmd)->len;
471
+ #endif
467
472
  if (len > 98)
468
473
  rb_raise (rb_eRuntimeError, "too many arguments to popen");
469
474
  char *strings [100];
@@ -510,6 +515,20 @@ static VALUE t__epoll (VALUE self)
510
515
  return Qnil;
511
516
  }
512
517
 
518
+ /**********
519
+ t__epoll_p
520
+ **********/
521
+
522
+ static VALUE t__epoll_p (VALUE self)
523
+ {
524
+ #ifdef HAVE_EPOLL
525
+ return Qtrue;
526
+ #else
527
+ return Qfalse;
528
+ #endif
529
+ }
530
+
531
+
513
532
  /*********
514
533
  t__kqueue
515
534
  *********/
@@ -521,6 +540,19 @@ static VALUE t__kqueue (VALUE self)
521
540
  return Qnil;
522
541
  }
523
542
 
543
+ /***********
544
+ t__kqueue_p
545
+ ***********/
546
+
547
+ static VALUE t__kqueue_p (VALUE self)
548
+ {
549
+ #ifdef HAVE_KQUEUE
550
+ return Qtrue;
551
+ #else
552
+ return Qfalse;
553
+ #endif
554
+ }
555
+
524
556
 
525
557
  /****************
526
558
  t_send_file_data
@@ -585,6 +617,23 @@ static VALUE conn_associate_callback_target (VALUE self, VALUE sig)
585
617
  }
586
618
 
587
619
 
620
+ /***************
621
+ t_get_loop_time
622
+ ****************/
623
+
624
+ static VALUE t_get_loop_time (VALUE self)
625
+ {
626
+ VALUE cTime = rb_path2class("Time");
627
+ if (gCurrentLoopTime != 0) {
628
+ return rb_funcall(cTime,
629
+ rb_intern("at"),
630
+ 1,
631
+ INT2NUM(gCurrentLoopTime));
632
+ }
633
+ return Qnil;
634
+ }
635
+
636
+
588
637
  /*********************
589
638
  Init_rubyeventmachine
590
639
  *********************/
@@ -634,6 +683,8 @@ extern "C" void Init_rubyeventmachine()
634
683
  rb_define_module_function (EmModule, "attach_fd", (VALUE (*)(...))t_attach_fd, 3);
635
684
  rb_define_module_function (EmModule, "detach_fd", (VALUE (*)(...))t_detach_fd, 1);
636
685
 
686
+ rb_define_module_function (EmModule, "current_time", (VALUE(*)(...))t_get_loop_time, 0);
687
+
637
688
  rb_define_module_function (EmModule, "open_udp_socket", (VALUE(*)(...))t_open_udp_socket, 2);
638
689
  rb_define_module_function (EmModule, "read_keyboard", (VALUE(*)(...))t_read_keyboard, 0);
639
690
  rb_define_module_function (EmModule, "release_machine", (VALUE(*)(...))t_release_machine, 0);
@@ -661,6 +712,9 @@ extern "C" void Init_rubyeventmachine()
661
712
  rb_define_module_function (EmModule, "epoll", (VALUE(*)(...))t__epoll, 0);
662
713
  rb_define_module_function (EmModule, "kqueue", (VALUE(*)(...))t__kqueue, 0);
663
714
 
715
+ rb_define_module_function (EmModule, "epoll?", (VALUE(*)(...))t__epoll_p, 0);
716
+ rb_define_module_function (EmModule, "kqueue?", (VALUE(*)(...))t__kqueue_p, 0);
717
+
664
718
  rb_define_method (EmConnection, "get_outbound_data_size", (VALUE(*)(...))conn_get_outbound_data_size, 0);
665
719
  rb_define_method (EmConnection, "associate_callback_target", (VALUE(*)(...))conn_associate_callback_target, 1);
666
720
 
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: sigs.cpp 668 2008-01-04 23:00:34Z blackhedd $
3
+ $Id$
4
4
 
5
5
  File: sigs.cpp
6
6
  Date: 06Apr06
data/ext/sigs.h CHANGED
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: sigs.h 668 2008-01-04 23:00:34Z blackhedd $
3
+ $Id$
4
4
 
5
5
  File: sigs.h
6
6
  Date: 06Apr06
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: ssl.cpp 673 2008-01-05 04:33:01Z blackhedd $
3
+ $Id$
4
4
 
5
5
  File: ssl.cpp
6
6
  Date: 30Apr06
data/ext/ssl.h CHANGED
@@ -1,6 +1,6 @@
1
1
  /*****************************************************************************
2
2
 
3
- $Id: ssl.h 668 2008-01-04 23:00:34Z blackhedd $
3
+ $Id$
4
4
 
5
5
  File: ssl.h
6
6
  Date: 30Apr06
@@ -0,0 +1,196 @@
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
+ *
31
+ */
32
+ package com.rubyeventmachine;
33
+
34
+ import java.nio.ByteBuffer;
35
+ import java.nio.channels.*;
36
+ import java.util.*;
37
+ import java.io.*;
38
+ import java.net.*;
39
+ import java.net.SocketAddress;
40
+
41
+ /**
42
+ * @author francis
43
+ *
44
+ */
45
+ public class Application {
46
+
47
+
48
+ public class Reactor extends EmReactor {
49
+
50
+ private Application application;
51
+ private TreeMap<String, Timer> timers;
52
+ private TreeMap<String, Connection> connections;
53
+ private TreeMap<String, ConnectionFactory> acceptors;
54
+ /**
55
+ *
56
+ */
57
+ public Reactor (Application app) {
58
+ application = app;
59
+ timers = new TreeMap<String, Timer>();
60
+ connections = new TreeMap<String, Connection>();
61
+ acceptors = new TreeMap<String, ConnectionFactory>();
62
+ }
63
+
64
+
65
+ public void eventCallback (String sig, int eventType, ByteBuffer data) {
66
+ if (eventType == EM_TIMER_FIRED) {
67
+ String timersig = new String (data.array());
68
+ //System.out.println ("EVSIG "+sig + "..."+new String(data.array()));
69
+ Timer r = timers.remove(timersig);
70
+ if (r != null)
71
+ r._fire();
72
+ else
73
+ throw new RuntimeException ("unable to run unknown timer");
74
+ }
75
+ else if (eventType == EM_CONNECTION_COMPLETED) {
76
+ Connection c = connections.get(sig);
77
+ if (c != null) {
78
+ c.connectionCompleted();
79
+ }
80
+ else
81
+ throw new RuntimeException ("connection completed to unknown object");
82
+
83
+ }
84
+ else if (eventType == EM_CONNECTION_UNBOUND) {
85
+ Connection c = connections.get(sig);
86
+ if (c != null) {
87
+ c.unbind();
88
+ }
89
+ else
90
+ throw new RuntimeException ("unbind received on unknown object");
91
+ }
92
+ else if (eventType == EM_CONNECTION_ACCEPTED) {
93
+ ConnectionFactory f = acceptors.get(sig);
94
+ if (f != null) {
95
+ Connection c = f.connection();
96
+ c.signature = new String (data.array());
97
+ c.application = application;
98
+ connections.put(c.signature, c);
99
+ c.postInit();
100
+ //System.out.println (sig+"..."+new String(data.array()));
101
+ }
102
+ else
103
+ throw new RuntimeException ("received connection on unknown acceptor");
104
+ }
105
+ else if (eventType == EM_CONNECTION_READ) {
106
+ Connection c = connections.get(sig);
107
+ if (c != null) {
108
+ c.receiveData(data);
109
+ }
110
+ else throw new RuntimeException ("received data on unknown object");
111
+ }
112
+ else {
113
+ System.out.println ("unknown event type: " + eventType);
114
+ }
115
+ }
116
+ }
117
+
118
+
119
+ Reactor reactor;
120
+
121
+ public Application() {
122
+ reactor = new Reactor (this);
123
+ }
124
+ public void addTimer (double seconds, Timer t) {
125
+ t.application = this;
126
+ t.interval = seconds;
127
+ String s = reactor.installOneshotTimer ((int)(seconds * 1000));
128
+ reactor.timers.put(s, t);
129
+
130
+ }
131
+
132
+ public void connect (String host, int port, Connection c) {
133
+ try {
134
+ String s = reactor.connectTcpServer(host, port);
135
+ c.application = this;
136
+ c.signature = s;
137
+ reactor.connections.put(s, c);
138
+ c.postInit();
139
+ } catch (ClosedChannelException e) {}
140
+ }
141
+
142
+ public void startServer (SocketAddress sa, ConnectionFactory f) throws EmReactorException {
143
+ String s = reactor.startTcpServer(sa);
144
+ reactor.acceptors.put(s, f);
145
+ }
146
+
147
+ public void stop() {
148
+ reactor.stop();
149
+ }
150
+ public void run() {
151
+ try {
152
+ reactor.run();
153
+ } catch (IOException e) {}
154
+ }
155
+ public void run (final Runnable r) {
156
+ addTimer(0, new Timer() {
157
+ public void fire() {
158
+ r.run();
159
+ }
160
+ });
161
+ run();
162
+ }
163
+
164
+ public void sendData (String sig, ByteBuffer bb) {
165
+ try {
166
+ reactor.sendData(sig, bb);
167
+ } catch (IOException e) {}
168
+ }
169
+
170
+ public void sendDatagram (String sig, ByteBuffer bb, InetSocketAddress target) {
171
+ reactor.sendDatagram(sig, bb, target.getHostName(), target.getPort());
172
+ }
173
+
174
+ public void closeConnection (String sig, boolean afterWriting) {
175
+ try {
176
+ reactor.closeConnection(sig, afterWriting);
177
+ } catch (ClosedChannelException e) {}
178
+ }
179
+
180
+ public void openDatagramSocket (Connection c) {
181
+ openDatagramSocket (new InetSocketAddress ("0.0.0.0", 0), c);
182
+ }
183
+ public void openDatagramSocket (InetSocketAddress addr, Connection c) {
184
+ try {
185
+ String s = reactor.openUdpSocket(addr);
186
+ c.application = this;
187
+ c.signature = s;
188
+ reactor.connections.put(s, c);
189
+ c.postInit();
190
+ } catch (ClosedChannelException e) {
191
+ } catch (IOException e) {
192
+ System.out.println ("Bad Datagram socket "+e+" "+addr);
193
+ /* TODO, can't catch this here, because it can happen on a bad address */
194
+ }
195
+ }
196
+ }
@@ -0,0 +1,74 @@
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
+
31
+ package com.rubyeventmachine;
32
+
33
+ //import java.io.*;
34
+ import java.nio.*;
35
+ import java.net.*;
36
+ //import java.nio.channels.*;
37
+
38
+ public class Connection {
39
+
40
+ public Application application;
41
+ public String signature;
42
+
43
+ public void postInit() {}
44
+ public void connectionCompleted() {}
45
+ public void unbind() {}
46
+ public void receiveData (ByteBuffer bytebuffer) {}
47
+
48
+
49
+ /**
50
+ * Called by user code.
51
+ * @param bytebuffer
52
+ */
53
+ public void sendData (ByteBuffer b) {
54
+ application.sendData(signature, b);
55
+ }
56
+
57
+ /**
58
+ * This is called by user code.
59
+ * TODO: don't expose the exception here.
60
+ */
61
+ public void close() {
62
+ application.closeConnection(signature, false);
63
+ }
64
+ /**
65
+ * This is called by user code/
66
+ */
67
+ public void closeAfterWriting() {
68
+ application.closeConnection(signature, true);
69
+ }
70
+
71
+ public void sendDatagram (ByteBuffer bb, InetSocketAddress addr) {
72
+ application.sendDatagram (signature, bb, addr);
73
+ }
74
+ }