code: public void onStateChange() {
          switch (dataChannel.state()) {
              case CONNECTING:
                  break;
  
              case OPEN: {
                      if (null != callReference) {
                          RespokeCall call = callReference.get();
                          if (null != call) {
                              call.directConnectionDidOpen(this);
                          }
                      }
  
                  new Handler(Looper.getMainLooper()).post(new Runnable() {
                      public void run() {
                          if (null != listenerReference) {
                              Listener listener = listenerReference.get();
                              if (null != listener) {
                                  listener.onOpen(RespokeDirectConnection.this);
                              }
                          }
                      }
                  });
                  }
                  break;
  
              case CLOSING:
                  break;
  
              case CLOSED: {
                      if (null != callReference) {
                          RespokeCall call = callReference.get();
                          if (null != call) {
                              call.directConnectionDidClose(this);
                          }
                      }
  
                      new Handler(Looper.getMainLooper()).post(new Runnable() {
                          public void run() {
                              if (null != listenerReference) {
                                  Listener listener = listenerReference.get();
                                  if (null != listener) {
                                      listener.onClose(RespokeDirectConnection.this);
                                  }
                              }
                          }
                      });
                  }
                  break;
          }
      }
docs: org.webrtc.DataChannel.Observer methods