@Override
        public void onSuccess(PomeloClient client, JSONObject jsonObject) {
          try {
            JSONObject connectorJson = new JSONObject();
            String username = "******";
            String rid = "a";
            connectorJson.put("username", username);
            connectorJson.put("rid", rid);
            client.request(
                "connector.entryHandler.enter",
                connectorJson.toString(),
                new OnDataHandler() {

                  @Override
                  public void onData(PomeloMessage.Message message) {
                    System.out.println(message.toString());
                    flag = true;
                  }
                });
          } catch (JSONException e) {
            e.printStackTrace();
            flag = true;
          } catch (PomeloException e) {
            e.printStackTrace();
            flag = true;
          }
        }
 @Test
 public void testConnect() throws InterruptedException {
   try {
     final PomeloClient client = new PomeloClient(new URI("ws://localhost:3014"));
     //            List<Runnable> runs = new ArrayList<Runnable>();
     //            runs.add(client);
     //            PomeloClientTest.assertConcurrent("test websocket client", runs, 200);
     OnHandshakeSuccessHandler onHandshakeSuccessHandler =
         new OnHandshakeSuccessHandler() {
           @Override
           public void onSuccess(PomeloClient _client, JSONObject resp) {
             try {
               JSONObject json = new JSONObject();
               json.put("uid", 1);
               client.request(
                   "gate.gateHandler.queryEntry",
                   json.toString(),
                   new OnDataHandler() {
                     @Override
                     public void onData(PomeloMessage.Message message) {
                       try {
                         JSONObject bodyJson = message.getBodyJson();
                         String host = bodyJson.getString(PomeloClient.HANDSHAKE_RES_HOST_KEY);
                         String port = bodyJson.getString(PomeloClient.HANDSHAKE_RES_PORT_KEY);
                         client.close();
                         PomeloClient connector =
                             new PomeloClient(new URI("ws://" + host + ":" + port));
                         connector.setOnHandshakeSuccessHandler(
                             onConnectorHandshakeSuccessHandler);
                         connector.setOnErrorHandler(onErrorHandler);
                         connector.connect();
                       } catch (JSONException e) {
                         e
                             .printStackTrace(); // To change body of catch statement use File |
                                                 // Settings | File Templates.
                         flag = true;
                       } catch (URISyntaxException e) {
                         e
                             .printStackTrace(); // To change body of catch statement use File |
                                                 // Settings | File Templates.
                         flag = true;
                       }
                     }
                   });
             } catch (PomeloException e) {
               e
                   .printStackTrace(); // To change body of catch statement use File | Settings |
                                       // File Templates.
               flag = true;
             } catch (JSONException e) {
               e
                   .printStackTrace(); // To change body of catch statement use File | Settings |
                                       // File Templates.
               flag = true;
             }
           }
         };
     client.setOnHandshakeSuccessHandler(onHandshakeSuccessHandler);
     client.setOnErrorHandler(onErrorHandler);
     client.connect();
     while (!flag) {
       Thread.sleep(100);
     }
   } catch (URISyntaxException e) {
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   }
 }