Examples of BaseClient


Examples of com.corundumstudio.socketio.transport.BaseClient

    @Override
    protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, PacketsMessage message)
                throws Exception {
        ByteBuf content = message.getContent();
        BaseClient client = message.getClient();

        if (log.isTraceEnabled()) {
            log.trace("In message: {} sessionId: {}", content.toString(CharsetUtil.UTF_8), client.getSessionId());
        }
        while (content.isReadable()) {
            try {
                Packet packet = decoder.decodePackets(content, client.getSessionId());
                Namespace ns = namespacesHub.get(packet.getEndpoint());

                NamespaceClient nClient = (NamespaceClient) client.getChildClient(ns);
                packetListener.onPacket(packet, nClient);
            } catch (Exception ex) {
                String c = content.toString(CharsetUtil.UTF_8);
                log.error("Error during data processing. Client sessionId: " + client.getSessionId() + ", data: " + c, ex);
            }
        }
    }
View Full Code Here

Examples of com.corundumstudio.socketio.transport.BaseClient

            throws Exception {
        Object msg = e.getMessage();
        if (msg instanceof PacketsMessage) {
            PacketsMessage message = (PacketsMessage) msg;
            ChannelBuffer content = message.getContent();
            BaseClient client = message.getClient();

            if (log.isTraceEnabled()) {
                log.trace("In message: {} sessionId: {}", new Object[] {content.toString(CharsetUtil.UTF_8), client.getSessionId()});
            }
            while (content.readable()) {
                Packet packet = decoder.decodePackets(content, client.getSessionId());
                Namespace ns = namespacesHub.get(packet.getEndpoint());

                NamespaceClient nClient = (NamespaceClient) client.getChildClient(ns);
                packetListener.onPacket(packet, nClient);
            }
        } else {
            ctx.sendUpstream(e);
        }
View Full Code Here

Examples of com.corundumstudio.socketio.transport.BaseClient

            throws Exception {
        Object msg = e.getMessage();
        if (msg instanceof PacketsMessage) {
            PacketsMessage message = (PacketsMessage) msg;
            ChannelBuffer content = message.getContent();
            BaseClient client = message.getClient();

            if (log.isTraceEnabled()) {
                log.trace("In message: {} sessionId: {}", new Object[] {content.toString(CharsetUtil.UTF_8), client.getSessionId()});
            }
            while (content.readable()) {
                try {
                    Packet packet = decoder.decodePackets(content, client.getSessionId());
                    Namespace ns = namespacesHub.get(packet.getEndpoint());

                    NamespaceClient nClient = (NamespaceClient) client.getChildClient(ns);
                    packetListener.onPacket(packet, nClient);
                } catch (Exception ex) {
                    String c = content.toString(CharsetUtil.UTF_8);
                    log.error("Error during data processing. Client sessionId: " + client.getSessionId() + ", data: " + c, ex);
                }
            }
        } else {
            ctx.sendUpstream(e);
        }
View Full Code Here

Examples of com.corundumstudio.socketio.transport.BaseClient

    @Override
    protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, PacketsMessage message)
                throws Exception {
        ByteBuf content = message.getContent();
        BaseClient client = message.getClient();

        if (log.isTraceEnabled()) {
            log.trace("In message: {} sessionId: {}", content.toString(CharsetUtil.UTF_8), client.getSessionId());
        }
        while (content.isReadable()) {
            try {
                Packet packet = decoder.decodePackets(content, client.getSessionId());
                Namespace ns = namespacesHub.get(packet.getEndpoint());

                NamespaceClient nClient = (NamespaceClient) client.getChildClient(ns);
                packetListener.onPacket(packet, nClient);
            } catch (Exception ex) {
                String c = content.toString(CharsetUtil.UTF_8);
                log.error("Error during data processing. Client sessionId: " + client.getSessionId() + ", data: " + c, ex);
                return;
            }
        }
    }
View Full Code Here

Examples of com.golden.gamedev.engine.BaseClient

    // we need to register our custom packet first
    NetworkConfig.registerPacket((short) 1, AllFieldTypePacket.class);
    NetworkConfig.DEBUG = true;
   
    try {
      BaseClient bsClient = new TCPClient(host, port); // create client
                                // and connect
                                // to server
     
      int sendCounter = 0;
     
      System.out.println("Start the Client...");
     
      // network loop
      while (true) {
        bsClient.update(100); // the main work
       
        // send packet to server
        // every 50 tick
        if (++sendCounter % 50 == 0) {
          bsClient.sendPacket(new AllFieldTypePacket());
        }
       
        // disconnect from server
        // after 200 tick
        if (sendCounter > 200) {
          bsClient.silentDisconnect();
          break;
        }
       
        try {
          Thread.sleep(100);
View Full Code Here

Examples of com.mdraco.chat.BaseClient

      }
    }
    else if (args.length > 0 && args[0].equalsIgnoreCase("c")) {
      System.out.println("client mode started");
      try {
        BaseClient c = new ConsoleClient("localhost", port);

        String text = reader.readLine();
        while (!text.equalsIgnoreCase("q") && !text.equalsIgnoreCase("quit")) {
          c.Send(text);
          text = reader.readLine();
        }
        c.Close();
      } catch (IOException e) {
        e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
      }
    }
    else {
View Full Code Here

Examples of org.apache.vinci.transport.BaseClient

    try {
      VNSQuery vq = new VNSQuery(args[0], Integer.parseInt(args[1]));

      ArrayList list = vq.getServices(args[2]);
      System.out.println("Got::" + list.size() + " Services");
      BaseClient client = null;
      for (int i = 0; i < list.size(); i++) {
        Object ob = list.get(i);
        if (ob != null) {
          System.out.println(((VinciServiceInfo) ob).toString());
          VinciServiceInfo serviceInfo = (VinciServiceInfo) ob;
          if (serviceInfo != null) {
            try {
              client = new BaseClient(serviceInfo.getHost(), serviceInfo.getPort());
              if (client.isOpen()) {
                System.out.println("Service::" + serviceInfo.getServiceName() + " is alive");
              }
            } catch (ConnectException ce) {
              System.out.println("Service::" + serviceInfo.getServiceName() + " is down");
            }
View Full Code Here

Examples of org.apache.vinci.transport.BaseClient

     *           unable to connect to VNS
     */
    public VinciVNSQuery(String aVnsHost, int aVnsPort) throws Exception {
      vnsHost = aVnsHost;
      vnsPort = aVnsPort;
      vnsConnection = new BaseClient(vnsHost, vnsPort);
    }
View Full Code Here

Examples of org.apache.vinci.transport.BaseClient

     * @throws Exception -
     *           error while looking up the service
     */
    public ArrayList getVinciServices(String aVinciServiceName) throws Exception {
      ArrayList serviceList = new ArrayList();
      BaseClient client = null;
      // make sure we got a valid connection to VNS
      if (vnsConnection != null && vnsConnection.isOpen()) {
        // Set up VNS query
        VinciFrame queryFrame = new VinciFrame();
        queryFrame.fadd("vinci:COMMAND", "getlist");
        queryFrame.fadd("PREFIX", aVinciServiceName);
        // System.out.println("Query Frame:::"+queryFrame.toXML());
        // Query the VNS
        VinciFrame response = (VinciFrame) vnsConnection.sendAndReceive(queryFrame);
        ArrayList serviceFrames = response.fget("SERVICE");
        // Each service is returned in its own SERVICE frame. So cycle through those now
        // one at a time
        for (int i = 0; i < serviceFrames.size(); i++) {
          VinciFrame serviceFrame = (VinciFrame) serviceFrames.get(i);
          // Copy data from the frame ( host, port etc)
          VinciServiceInfo serviceInfo = getServiceInfo(serviceFrame);
          if (serviceInfo != null) {
            // Test the service for availability. Use only those services that respond. The list
            // may contain stale services that are not running
            try {
              // Establish a brief connection to test for availability. This test fails gracefully
              // Its not an error if the service does not respond. The retry logic is done
              // elsewhere.
              client = new BaseClient(serviceInfo.getHost(), serviceInfo.getPort());
              if (client.isOpen()) {
                if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
                  UIMAFramework.getLogger(this.getClass()).logrb(
                          Level.FINEST,
                          this.getClass().getName(),
                          "initialize",
                          CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                          "UIMA_CPM_service_active_on_port__FINEST",
                          new Object[] { Thread.currentThread().getName(),
                              serviceInfo.getServiceName(), serviceInfo.getHost(),
                              String.valueOf(serviceInfo.getPort()) });
                }
                // Service is ok, so add it to the list
                serviceList.add(serviceInfo);
              }
            } catch (ConnectException ce) {
              if (UIMAFramework.getLogger().isLoggable(Level.WARNING)) {
                UIMAFramework.getLogger(this.getClass()).logrb(
                        Level.WARNING,
                        this.getClass().getName(),
                        "initialize",
                        CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                        "UIMA_CPM_service_not_active_on_port__WARNING",
                        new Object[] { Thread.currentThread().getName(),
                            serviceInfo.getServiceName(), serviceInfo.getHost(),
                            String.valueOf(serviceInfo.getPort()) });
              }
            } finally {
              // Drop the connection if necessary.
              if (client != null) {
                try {
                  client.close();
                } catch (Exception ex) {
                }
              }
            }
          }
View Full Code Here

Examples of org.apache.vinci.transport.BaseClient

        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_vns_redirect__FINEST",
                  new Object[] { Thread.currentThread().getName(), publicVNSHost, publicVNSPort });
        }
        BaseClient client = new BaseClient(publicVNSHost, pvnsPort);
        return client.sendAndReceive(in);
      } else {
        if (UIMAFramework.getLogger().isLoggable(Level.WARNING)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.WARNING, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_unknown_vns_command__WARNING",
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.