Changeset 450
- Timestamp:
- 07/19/07 23:21:39 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
version_0/java/src/com/rubyeventmachine/EmReactor.java
r448 r450 158 158 EventableChannel ec = (EventableChannel)k.attachment(); 159 159 if (!ec.writeOutboundData()) { 160 eventCallback (ec.getBinding(), EM_CONNECTION_UNBOUND, EmptyByteBuffer); 160 161 Connections.remove (ec.getBinding()); 161 162 k.channel().close(); … … 240 241 } 241 242 243 public void sendData (String sig, ByteBuffer bb) throws IOException { 244 (Connections.get(sig)).scheduleOutboundData( bb ); 245 } 242 246 public void sendData (String sig, String data, int length) throws IOException { 243 (Connections.get(sig)).scheduleOutboundData( ByteBuffer.wrap(data.getBytes())); 247 sendData (sig, ByteBuffer.wrap(data.getBytes())); 248 //(Connections.get(sig)).scheduleOutboundData( ByteBuffer.wrap(data.getBytes())); 244 249 } 245 250 … … 280 285 281 286 public void closeConnection (String sig, boolean afterWriting) throws ClosedChannelException { 287 //System.out.println ("???"+Connections.get(sig)); 282 288 Connections.get(sig).scheduleClose (afterWriting); 283 289 } version_0/java/src/com/rubyeventmachine/EventableChannel.java
r438 r450 81 81 break; 82 82 } 83 83 84 84 if (OutboundQ.isEmpty()) 85 85 myChannel.register(mySelector, SelectionKey.OP_READ, this); version_0/java/src/com/rubyeventmachine/tests/TestTimers.java
r447 r450 1 1 package com.rubyeventmachine.tests; 2 2 3 import com.rubyeventmachine.*; 4 import java.io.*; 3 5 6 import org.junit.Assert; 4 7 import org.junit.After; 5 8 import org.junit.AfterClass; … … 27 30 } 28 31 32 33 29 34 @Test 30 public final void test Timer1(){31 System.out.println (">>>");32 class x implements Runnable{33 public void run() {34 System.out.println ("running");35 public final void test2() throws IOException { 36 Application a = new Application(); 37 a.addTimer(0, new Timer() { 38 public void fire() { 39 application.stop(); 35 40 } 36 }; 37 new x().run(); 41 }); 42 a.run(); 43 Assert.assertEquals (1, 1); // just to make sure the reactor halts. 38 44 } 39 45 40 46 @Test 47 public final void test3() throws IOException { 48 Application a = new Application(); 49 a.addTimer (0.1, new PeriodicTimer() { 50 int n = 0; 51 public void fire() { 52 n++; 53 if (n == 5) 54 application.stop(); 55 } 56 }); 57 a.run(); 58 Assert.assertEquals(1, 1); 59 } 41 60 }
