How to disconnect user from sendPrivateChat ?

0 votes
I am making chat application and i am using sendPrivateChat method to communicate user in private mode. but i want to disconnect user when user press back button of android device. so can you please tell me how to disconnect user from private chat mode. ? i have used appwrap service in android. Thanks in Advance.
asked Sep 28, 2016 in Android by bhavesh (16 points)

1 Answer

0 votes

HI Bhavesh,

Greetings!!

You can use disConnect API to disconnect user from AppWarp on back button event.But it will disConenct  the respective user.

But If you want to disable private chat option only without disConnecting the user, in this case you need to write own businees login. You can manage a flag in Shared Pref and can enable the private Chat mode accordingly.

Let me know if it helps.

Thanks

Vishnu Garg

answered Sep 28, 2016 by Vishnu Garg (674 points)
but when  i am disconnecting user then i got disconnect_error when i try to connect user second time for private chat
should i connect user second time if i want to send message using sendprivatechat api ?
can you please tell me syntax for disConnect API ?
warpClient.disconnect(); Let me know which error code you are getting while disconnecting.
should i connect user second time if i want to send message using sendprivatechat api ?

or i can directly call  sendprivatechat api ?
As you are calling disConnect API you need to connect again before calling sendPrivateChat API.
If you don't want to disConnect you can opt second solution by maintaining a flag inside your application.
Again it will depend on your logic how you want to implement the same.
i disconnect user when user press back button
but when i am trying to connect user second time i am getting CONNECTION_ERROR in onSendPrivateChatDone api
and i am getting messages twice of a single message if i have not disconnect user
Have you call the connectWithUserName API and received the success result in onConnectDone method before calling sendPrivateChat.
You are receiving coonection_error because user in not connected successfully with the server.
please help me to solve this
 i am getting messages twice of a single message if i have not disconnect user
Let me know the case how you are getting two messages. You will get message form sender in onPrivateChatReceived method and in onSendPrivateChatDone  you will get result when  you are sending the message.
can you please tell me what is the meaning of below statement ?
 theClient = WarpClient.getInstance();
because i think that i opening activity twice without disconnecting user so that may be it send me msg twice
It will create a single object of theClient  throughout  the application. Yes it can be a case as you are resuming the application, can you test the same by attaching logs in onPrivateChatReceived  method so that can trace the exact problem in Android side. As AppWarp server never sends a same message again.
i already put log in onPrivateChatReceived and application display log twice
is there any way to close private chat between two user when user press back button ?
So you are getting the twice message when application opens again?Or you are opening again and again and you will be getting the same message again. Is it happening while resume pause in a little period of time.The only way is disConnect API
are you saying i have to call   theclient.disconnect() ?
Yes,You need to call DisConnect API, so that if your application is background it disconnect the user from server.
ok Thanks
can you please tell me what is the reason for null pointer exception
 though i have check event!=null i am getting null pointer exception in
 event.getJoinedUsers().length
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...