1

First of all this question has no duplicate, because in this question there's only toast problem [Android Emitter.Listener not working. I have no problem with toast. I'm using SocketCluster https://github.com/sacOO7/socketcluster-client-java, not Sokcet.IO . So my problem is, that Emitter.Listener not works. I'm connecting successfully, but in that listener i need to give my tokens, else in server there will be some exceptions. Server says that it not gets PONG from client.

Now I'll add link and there are pictures. There I'm explaining my problem very well, so you can understand easier.

Here's the code too.

  public void socketCall(final JSONObject jsonObject) {

  Thread thread = new Thread(new Runnable() {
      @Override
      public void run() {
          Emitter.Listener listener = new Emitter.Listener() {
              @Override
              public void call(String name, Object data) {
                  Log.d("4564323", "AAA");
                  data = jsonObject;
                  sc.emit("auth", data);
              }
          };



sc.on("connect" , listener);

 sc.createChannel(
 SharedPreferencesManager.getInstance().getUsername());

  sc.connect();



if(!sc.isconnected()) {
              sc.setReconnection(new 
              ReconnectStrategy().setDelay(2000).setMaxAttempts(10));
          }
          Log.d("4564323", socket.getCurrentState().toString());

      }
  });

thread.start();

}
Zoe
  • 27,060
  • 21
  • 118
  • 148
Hayk Mkrtchyan
  • 2,835
  • 3
  • 19
  • 61

0 Answers0