本文介绍了QBUsers.signIn和QBChatService.login有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解这两个动作之间的区别.在聊天指南中说过,要使用聊天服务,我必须创建一个会话,然后调用login()- http://quickblox.com/developers/Android_XMPP_Chat_Sample#Login_to_Chat

I would like to understand what is the difference between the two actions. It's said in chat guide that in order to use the chat service, I have to create a session and then call login() - http://quickblox.com/developers/Android_XMPP_Chat_Sample#Login_to_Chat

,并在QBUsers指南中-创建一个会话并调用QBUsers.signIn- http://quickblox.com/developers/SimpleSample-users-android#Sign_In_.26_Social_authorization

and in the QBUsers guide - create a session and call QBUsers.signIn - http://quickblox.com/developers/SimpleSample-users-android#Sign_In_.26_Social_authorization

我不确定我必须做什么才能能够使用聊天并能够检索用户的个人资料数据,并因此拥有(我想向用户显示联系人的个人资料).因此,如果有人可以澄清这些功能之间的区别,我将不胜感激!提前致谢!

I'm not sure what do I have to do in order to be able to use the chat and to be able to retrieve users' profile data and so own (I want to display profiles of contacts to the user).So, if anyone could clarify the difference between those functions, I'd be very grateful!Thanks in advance!

推荐答案

Quickblox使用2个不同的会话,即1.User Session,2.Chat session.为了检索用户个人资料图片,对话框列表以及您需要用户会话的所有内容,为了无缝地接收和发送聊天,您将需要聊天会话.

Quickblox makes use of 2 different sessions, 1.User Session, 2.Chat session. In order to retrieve user profile pictures, dialogs list and every thing you will need user session and in order to receive and send chat seamlessly you will need chat session.

但是有一个陷阱.您无法在没有用户会话的情况下建立聊天会话.:)因此,您必须先建立一个用户会话,然后再建立一个聊天会话.

But there is a catch. You cant establish chat session without user session. :) So you have to establish a user session first and then establish chat session after that.

因此,当用户退出应用程序或应用程序终止时,您必须关闭聊天会话(无需关闭用户会话,这意味着您必须从聊天中注销而不是从用户会话中注销),并且一旦用户将应用程序置于前台检查用户会话和聊天会话是否已过期,然后重新建立会话.

So when user quits the app or when application terminates, you have to close the chat session (no need to close user session I mean you have to log out from chat not from user session) and once user brings the app to foreground check both user session and chat session whichever has expired and re-establish the same.

如果您想知道为什么我从未注销时就建立用户会话,那么根据文档,大约3个小时后,朋友用户会话会自动终止.因此,请检查是否存在用户会话,如果是,请检查聊天会话以建立所需的会话.

If you are wondering why to establish user session when I never logged out ,friend user session gets expiered automatically after 3 hours or so as per docs. So check if user session exists, if yes check chat session establish whichever is needed.

其他信息:与用户会话相比,聊天会话是短暂的.实际上,如果您有用户会话,则也可以为对话框获取聊天记录,但是如果没有聊天会话,则无法将聊天消息发送到该对话框.这就是我所说的为了无缝地接收和发送聊天,你需要聊天会话"的意思.

Additional info: Chat session is short lived compared to user session.In fact, you can fetch the chats as well for a dialog, if you have user session, but you cant send chat to that dialog without chat session. Thats what I meant when I said "in order to receive and send chat seamlessly you will need chat session".

希望它会有所帮助.如有任何疑问,可以为您提供帮助:)

Hope it helps. Any doubt am here to help you :)

这篇关于QBUsers.signIn和QBChatService.login有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 08:31