Package org.xsocket.connection

Examples of org.xsocket.connection.IWriteCompletionHandler


      
       
        try {
            for (int i = 0; i < 20; i++) {
               
                IWriteCompletionHandler ch = new IWriteCompletionHandler() {
                    public void onWritten(int written) throws IOException {
                        System.out.println("written " + written);
                    }
                   
                    public void onException(IOException ioe) {
View Full Code Here


     
      // completion handler adapter is only required in async mode
      if (dataSink.getFlushmode() == FlushMode.ASYNC) {
        final ByteBuffer[] bufs = nonBlockingStream.readByteBufferByLength(length);
       
        IWriteCompletionHandler adapter = new IWriteCompletionHandler() {
           
          public void onWritten(int length) throws IOException {
            flowControlOnWritten(dataSink);
            writeCompletionManager.onWritten(bufs, true);
          }
View Full Code Here

            final FutureResponseHandler respHdl = new FutureResponseHandler();
            final BodyDataSink dataSink = con.send(new HttpRequestHeader("POST", "http://localhost:" + container.getLocalPort() + "/test"), respHdl);
            dataSink.setFlushmode(FlushMode.ASYNC);
           
           
            IWriteCompletionHandler completionHandler1 = new IWriteCompletionHandler() {
               
                public void onWritten(int written) throws IOException {
                    try {
                        IHttpResponse response = respHdl.getResponse();
                        Assert.assertEquals(200, response.getStatus());
                       
                        final BodyDataSource dataSource = response.getBody();
                        Assert.assertEquals("test", dataSource.readStringByLength(4));
                       
   
                        IWriteCompletionHandler completionHandler2 = new IWriteCompletionHandler() {
                           
                            public void onWritten(int written) throws IOException {
                                Assert.assertEquals("12345", dataSource.readStringByLength(5));

                                IWriteCompletionHandler completionHandler3 = new IWriteCompletionHandler() {
                                   
                                    public void onWritten(int written) throws IOException {
                                        Assert.assertEquals("789", dataSource.readStringByLength(3));
                                        dataSink.close();
                                    }
View Full Code Here

           
            retrievePrevious();
           
            int size = buffer.remaining();
           
            IWriteCompletionHandler compHdl = null;
           
            if (delegate.isNetworkendpoint() && isAutosuspendThresholdExceeded()) {
                NonBlockingBodyDataSource.this.suspend();
                compHdl = new AutoflowControlWriteCompletionHandler();
            } else {
View Full Code Here

            }

            retrievePrevious();

            int size = HttpUtils.computeRemaining(buffers);
            IWriteCompletionHandler compHdl = null;

            if (delegate.isNetworkendpoint() && isAutosuspendThresholdExceeded()) {
                NonBlockingBodyDataSource.this.suspend();
                compHdl = new AutoflowControlWriteCompletionHandler();
            } else {
View Full Code Here

                }
            }
           
           
            if (writeCompletionHandler == null) {
                IWriteCompletionHandler compHdl = null;
               
                if (delegate.isNetworkendpoint() && isAutosuspendThresholdExceeded()) {
                    NonBlockingBodyDataSource.this.suspend();
                    compHdl = new AutoflowControlWriteCompletionHandler();
                } else {
View Full Code Here

     
      boolean isImmutable = isContentImmutable;
      ByteBuffer[] dataToWrite = drainWriteQueue();
      isContentImmutable = true;
         
      IWriteCompletionHandler completionHandler = null;
         
      if (!writeCompletionManager.isPendingCompletionConfirmationsEmtpy()) {
        if (LOG.isLoggable(Level.FINE)) {
          LOG.fine("[" + connectionId + "] write completion handlers are registered. perform write with WriteCompletionHandlerAdapter");
        }
View Full Code Here

      
       
        try {
            for (int i = 0; i < 20; i++) {
               
                IWriteCompletionHandler ch = new IWriteCompletionHandler() {
                    public void onWritten(int written) throws IOException {
                        System.out.println("written " + written);
                    }
                   
                    public void onException(IOException ioe) {
View Full Code Here

  public void forwardTo(final BodyDataSink bodyDataSink, final IBodyCompleteListener completeListener) throws IOException {
   
    StringBuilder sb = new StringBuilder();
    writeHeadersTo(sb);

    IWriteCompletionHandler ch = new IWriteCompletionHandler() {
     
      @Execution(Execution.NONTHREADED)
      public void onWritten(int written) throws IOException {
        dataSource.forwardTo(bodyDataSink, completeListener);
      }
View Full Code Here

      
       
        try {
            for (int i = 0; i < 20; i++) {
               
                IWriteCompletionHandler ch = new IWriteCompletionHandler() {
                    public void onWritten(int written) throws IOException {
                        System.out.println("written " + written);
                    }
                   
                    public void onException(IOException ioe) {
View Full Code Here

TOP

Related Classes of org.xsocket.connection.IWriteCompletionHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.