微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Mesibo onConnectionStatus-5和6

如何解决Mesibo onConnectionStatus-5和6

public class MainActivity extends AppCompatActivity implements Mesibo.ConnectionListener,Mesibo.MessageListener,

MesiboCall.MesiboCallListener { 类DemoUser { 公共字符串令牌; 公共字符串名称; 公共字符串地址; DemoUser(字符串令牌,字符串名称,字符串地址){ this.token =令牌; this.name =名称; this.address =地址; } }

    //Refer to the Get-Started guide to create two users and their access tokens
    DemoUser mUser1 = new DemoUser("fec7b785d5cd5c8776472ef1b3833598c99291a7f37a45f05e22160a68",

“ User-1”,“ revan”); DemoUser mUser2 = new DemoUser(“ 93fec203c9d68917355f49f8beef6668f69a4b81871492e66160a69”, “ User-2”,“ siddu”);

    DemoUser mRemoteUser;
    Mesibo.UserProfile mProfile;
    Mesibo.ReadDbSession mReadSession;

    View mLoginButton1,mLoginButton2,mSendButton,mUiButton,mAudioCallButton,mVideoCallButton;
    TextView mMessageStatus,mConnStatus;
    EditText mMessage;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      mLoginButton1 = findViewById(R.id.login1);
      mLoginButton2 = findViewById(R.id.login2);
      mSendButton = findViewById(R.id.send);
      mUiButton = findViewById(R.id.launchUI);
      mAudioCallButton = findViewById(R.id.audioCall);
      mVideoCallButton = findViewById(R.id.videoCall);
      mMessageStatus = findViewById(R.id.msgStatus);
      mConnStatus = findViewById(R.id.connStatus);
      mMessage = findViewById(R.id.message);

      mSendButton.setEnabled(false);
      mUiButton.setEnabled(false);
      mAudioCallButton.setEnabled(false);
      mVideoCallButton.setEnabled(false);

    }

    private void mesiboInit(DemoUser user,DemoUser remoteUser) {
      Mesibo api = Mesibo.getInstance();
      api.init(getApplicationContext());

      Mesibo.addListener(this);
      Mesibo.setSecureConnection(true);
      Mesibo.setAccesstoken(user.token);
      Mesibo.setDatabase("mydb",0);
      Mesibo.start();

      mRemoteUser = remoteUser;
      mProfile = new Mesibo.UserProfile();
      mProfile.address = remoteUser.address;
      mProfile.name = remoteUser.name;
      Mesibo.setUserProfile(mProfile,false);

      // disable login buttons
      mLoginButton1.setEnabled(false);
      mLoginButton2.setEnabled(false);

      // enable buttons
      mSendButton.setEnabled(true);
      mUiButton.setEnabled(true);
      mAudioCallButton.setEnabled(true);
      mVideoCallButton.setEnabled(true);


      MesiboCall.getInstance().init(getApplicationContext());
      MesiboCall.getInstance().setListener(this);

      // Read receipts are enabled only when App is set to be in foreground
      Mesibo.setAppInForeground(this,true);
      mReadSession = new Mesibo.ReadDbSession(mRemoteUser.address,this);
      mReadSession.enableReadReceipt(true);
      mReadSession.read(100);

    }
    public void onLoginUser1(View view) {
      mesiboInit(mUser1,mUser2);
    }

    public void onLoginUser2(View view) {
      mesiboInit(mUser2,mUser1);
    }
    public void onSendMessage(View view) {
      Mesibo.MessageParams p = new Mesibo.MessageParams();
      p.peer = mRemoteUser.address;
      p.flag = Mesibo.FLAG_READRECEIPT | Mesibo.FLAG_DELIVERYRECEIPT;
      Mesibo.sendMessage(p,Mesibo.random(),mMessage.getText().toString().trim());
      mMessage.setText("");
    }

    public void onLaunchMessagingUi(View view) {
      MesiboUI.launchMessageView(this,mRemoteUser.address,0);
    }

    public void onAudioCall(View view) {
      MesiboCall.getInstance().call(this,mProfile,false);

      public void onVideoCall(View view) {
        MesiboCall.getInstance().call(this,true);
      }

      @Override
      public void Mesibo_onConnectionStatus(int status) {
        mConnStatus.setText("Connection Status: " + status);

        ``
        `
HERE I AM GETTING STATUS 5 AND 6 
`
        ``
      }

      @Override
      public boolean Mesibo_onMessage(Mesibo.MessageParams messageParams,byte[] data) {
        try {
          String message = new String(data,"UTF-8");

          Toast toast = Toast.makeText(getApplicationContext(),message,Toast.LENGTH_SHORT);

          toast.setGravity(Gravity.CENTER_VERTICAL,0);

          toast.show();

        } catch (Exception e) {}

        return true;
      }

      @Override
      public void Mesibo_onMessageStatus(Mesibo.MessageParams messageParams) {
        mMessageStatus.setText("Message Status: " + messageParams.getStatus());
      }

      @Override
      public void Mesibo_onActivity(Mesibo.MessageParams messageParams,int i) {

      }

      @Override
      public void Mesibo_onLocation(Mesibo.MessageParams messageParams,Mesibo.Location location) {

      }

      @Override
      public void Mesibo_onFile(Mesibo.MessageParams messageParams,Mesibo.FileInfo fileInfo) {

      }

      @Override
      public boolean MesiboCall_onNotify(int i,Mesibo.UserProfile userProfile,boolean b) {
        return false;
      }

      @Override
      public MesiboVideoCallFragment MesiboCall_getVideoCallFragment(Mesibo.UserProfile userProfile) {
        return null;
      }

      @Override
      public MesiboAudioCallFragment MesiboCall_getAudioCallFragment(Mesibo.UserProfile userProfile) {
        return null;
      }

      @Override

      public Fragment MesiboCall_getIncomingAudioCallFragment(Mesibo.UserProfile

userProfile){ 返回null; } }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。