@Override
  protected void onStreamDropped(Stream stream) {
    MySubscriber p = mSubscriberStream.get(stream);
    if (p != null) {
      mSubscribers.remove(p);
      mSubscriberStream.remove(stream);
      mSubscriberConnection.remove(stream.getConnection().getConnectionId());
      mPagerAdapter.notifyDataSetChanged();

      presentText("\n" + p.getName() + " has left the chat");
    }
  }
  @Override
  protected void onSignalReceived(String type, String data, Connection connection) {

    if (type != null && "chat".equals(type) && connection != null) {
      String mycid = this.getConnection().getConnectionId();
      String cid = connection.getConnectionId();
      if (!cid.equals(mycid)) {
        MySubscriber p = mSubscriberConnection.get(cid);
        if (p != null) {
          presentMessage(p.getName(), data);
        }
      }
    }
  }
  @Override
  protected void onStreamReceived(Stream stream) {
    MySubscriber p = new MySubscriber(mContext, stream);

    // we can use connection data to obtain each user id
    p.setUserId(stream.getConnection().getData());

    // Subscribe audio only if we have more than one player
    if (mSubscribers.size() != 0) {
      p.setSubscribeToVideo(false);
    }

    // Subscribe to this player
    this.subscribe(p);

    mSubscribers.add(p);
    mSubscriberStream.put(stream, p);
    mSubscriberConnection.put(stream.getConnection().getConnectionId(), p);
    mPagerAdapter.notifyDataSetChanged();

    presentText("\n" + p.getName() + " has joined the chat");
  }