Examples of ClientContext


Examples of org.cspoker.server.xml.sockets.ClientContext

      int numBytesRead = client.read(buffer);

      if (numBytesRead == -1) {
        // No more bytes can be read from the channel
        logger.debug("channel has reached end-of-stream");
        ClientContext context = getContext(key, client);
        context.closeConnection();
      } else {
        logger.trace("Reading " + numBytesRead + " bytes from socket");
        // To read the bytes, flip the buffer
        buffer.flip();
        ClientContext context = getContext(key, client);
        StringBuilder stringBuilder = context.getBuffer();

        while (buffer.hasRemaining()) {
          boolean hasEnded = filterUntilEndNode();

          CharBuffer decoded = decoder.decode(filteredBuffer);
          logger.trace("Reading: \n" + decoded);
          stringBuilder.append(decoded);
          if (hasEnded) {
            endNode(stringBuilder, context);
          }
        }
      }
    } catch (IOException e) {
      logger.debug("Exception reading from socket, closing socket: "+e.getMessage());
      ClientContext context = getContext(key, client);
      context.closeConnection();
      // Rethrow exception as declared
      throw (e);
    }

  }
View Full Code Here

Examples of org.cspoker.server.xml.sockets.ClientContext

    }

  }

  private ClientContext getContext(SelectionKey key, SocketChannel client) {
    ClientContext context = (ClientContext) (key.attachment());
    if (context == null) {
      context = new ClientContext(client, selector, cspokerServer);
      key.attach(context);
    }
    return context;

  }
View Full Code Here

Examples of org.iremake.client.network.ClientContext

        final ServerContext server = RemoteServer.CONTEXT;
        server.start();
        LOG.log(Level.INFO, server.getStatus());

        // start and connect client
        final ClientContext client = RemoteClient.CONTEXT;
        client.start("localhost");

        client.send(Message.LOBBY_CHAT.createNew("Anyone wants to chat?"));

        // in 5s stop everything
        final Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                timer.cancel();
                client.stop();
                server.stop();
            }
        }, 5_000);

    }
View Full Code Here

Examples of org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.ClientContext

   public Object invoke(Object[] args)
   {
      ClientInvocation request = createRequest(args);
      ClientResponse response = (ClientResponse)request.invoke();
      ClientContext context = new ClientContext(request, response, entityExtractorFactory);
      return extractor.extractEntity(context, null);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.