floo::BMXClient

客户端

#include <bmx_client.h>

Inherits from floo::BMXNetworkListener

Public Functions

Name
BMXClientPtr create(BMXSDKConfigPtr config)
创建BMXClient
virtual ~BMXClient()
析构函数
virtual BMXSDKConfigPtr getSDKConfig() =0
获取SDK设置
virtual BMXUserService & getUserService() =0
获取用户Service
virtual BMXChatService & getChatService() =0
获取聊天Service
virtual BMXGroupService & getGroupService() =0
获取群组Service
virtual BMXRosterService & getRosterService() =0
获取好友Service
virtual BMXPushService & getPushService() =0
获取推送Service
virtual BMXErrorCode signUpNewUser(const std::string & username, const std::string & password, BMXUserProfilePtr & bmxUserProfilePtr) =0
注册新用户,username和password是必填参数
virtual BMXErrorCode signInByName(const std::string & name, const std::string & password) =0
通过用户名登录
virtual BMXErrorCode signInById(int64_t , const std::string & password) =0
通过用户ID登录
virtual BMXErrorCode fastSignInByName(const std::string & name, const std::string & password) =0
通过用户名快速登录(要求之前成功登录过,登录速度较快)
virtual BMXErrorCode fastSignInById(int64_t uid, const std::string & password) =0
通过用户ID快速登录(要求之前成功登录过,登录速度较快)
virtual BMXErrorCode signOut(int64_t uid =0, bool ignoreUnbindDevice =false) =0
退出登录
virtual BMXConnectStatus connectStatus() =0
获取当前和服务器的连接状态
virtual BMXSignInStatus signInStatus() =0
获取当前的登录状态
virtual void reconnect() =0
强制重新连接
virtual void onNetworkChanged(BMXNetworkType type, bool reconnect) =0
处理网络状态发送变化
virtual void disconnect() =0
断开网络连接
virtual BMXErrorCode changeAppId(const std::string & appId, const std::string & appSecret ="") =0
更改SDK的appId,本操作会同时更新BMXConfig中的appId。
virtual BMXErrorCode initializeServerConfig(bool isLocal) =0
获取app的服务器网络配置,在初始化SDK之后登陆之前调用,可以提前获取服务器配置加快登陆速度。
virtual void sendMessage(BMXMessagePtr msg) =0
发送消息,消息状态变化会通过listener通知,在发送群组消息且指定的群组为开启群组已读回执的情况下, 该接口会自动获取群成员列表id并且填充到message config中去,无需客户端自己进行群组成员列表的填充操作。

Protected Functions

Name
BMXClient()

Additional inherited members

Public Functions inherited from floo::BMXNetworkListener

Name
virtual ~BMXNetworkListener()

Public Functions Documentation

function create

static BMXClientPtr create(
    BMXSDKConfigPtr config
)

创建BMXClient

Parameters:

  • config 客户端本地已经创建好的BMXSDKConfig SDK配置对象

Return: BMXClientPtr

Example:

client = BMXClient::create(config);

function ~BMXClient

inline virtual ~BMXClient()

析构函数

Example:

function getSDKConfig

virtual BMXSDKConfigPtr getSDKConfig() =0

获取SDK设置

Return: BMXSDKConfigPtr

Example:

function getUserService

virtual BMXUserService & getUserService() =0

获取用户Service

Return: BMXUserService

Example:

client->getUserService().addUserListener(userListener);
client->getUserService().removeUserListener(userListener);
BMXErrorCode errorCode = client->getUserService().getProfile(profile, false);
BMXErrorCode errorCode = client->getUserService().setNickname(params[0]);

function getChatService

virtual BMXChatService & getChatService() =0

获取聊天Service

Return: BMXChatService

Example:

client->getChatService().addChatListener(chatListener);
client->getChatService().removeChatListener(chatListener);
BMXConversationList conversationList = client->getChatService().getAllConversations();
BMXErrorCode errorCode = client->getChatService().retrieveHistoryMessages(conversationList[0], 0, 10, list);

function getGroupService

virtual BMXGroupService & getGroupService() =0

获取群组Service

Return: BMXGroupService

Example:

client->getGroupService().addGroupListener(groupListener);
client->getGroupService().removeGroupListener(groupListener);
BMXErrorCode errorCode = client->getGroupService().search(groupId, group, false);
errorCode = client->getGroupService().setMyNickname(group, params[1]);
BMXErrorCode errorCode = client->getGroupService().search(groupId, group, false);
errorCode = client->getGroupService().join(group, params[1]);
BMXErrorCode errorCode = client->getGroupService().search(groupId, group, false);
errorCode = client->getGroupService().leave(group);

function getRosterService

virtual BMXRosterService & getRosterService() =0

获取好友Service

Return: BMXRosterService

Example:

client->getRosterService().addRosterListener(rosterListener);
client->getRosterService().removeRosterListener(rosterListener);
BMXErrorCode errorCode = client->getRosterService().apply(rosterId, params[1]);
BMXErrorCode errorCode = client->getRosterService().remove(rosterId);
BMXErrorCode errorCode = client->getRosterService().accept(rosterId);
BMXErrorCode errorCode = client->getRosterService().decline(rosterId, params[1]);

function getPushService

virtual BMXPushService & getPushService() =0

获取推送Service

Return: BMXPushService

Example:

function signUpNewUser

virtual BMXErrorCode signUpNewUser(
    const std::string & username,
    const std::string & password,
    BMXUserProfilePtr & bmxUserProfilePtr
) =0

注册新用户,username和password是必填参数

Parameters:

  • username 用户名
  • password 用户密码
  • bmxUserProfilePtr 注册成功后从该函数处获取新注册用户的Profile信息,初始传入指向为空的shared_ptr对象即可。

Return: BMXErrorCode

Example:

function signInByName

virtual BMXErrorCode signInByName(
    const std::string & name,
    const std::string & password
) =0

通过用户名登录

Parameters:

  • name 用户名
  • password 用户密码

Return: BMXErrorCode

Example:

BMXErrorCode errorCode = client->signInByName(params[0], params[1]);

function signInById

virtual BMXErrorCode signInById(
    int64_t ,
    const std::string & password
) =0

通过用户ID登录

Parameters:

  • int64_t 用户id
  • password 用户密码

Return: BMXErrorCode

Example:

function fastSignInByName

virtual BMXErrorCode fastSignInByName(
    const std::string & name,
    const std::string & password
) =0

通过用户名快速登录(要求之前成功登录过,登录速度较快)

Parameters:

  • name 用户名
  • password 用户密码(用于sdk在内部token到期时自动更新用户token)

Return: BMXErrorCode

Example:

function fastSignInById

virtual BMXErrorCode fastSignInById(
    int64_t uid,
    const std::string & password
) =0

通过用户ID快速登录(要求之前成功登录过,登录速度较快)

Parameters:

  • uid 用户id
  • password 用户密码(用于sdk在内部token到期时自动更新用户token)

Return: BMXErrorCode

Example:

function signOut

virtual BMXErrorCode signOut(
    int64_t uid =0,
    bool ignoreUnbindDevice =false
) =0

退出登录

Parameters:

  • uid 退出用户的uid(默认输入0则退出当前登陆用户)
  • ignoreUnbindDevice 用户退出时是否忽略解绑定设备操作。对应某些服务器不可访问的情况下忽略服务器解绑定设备操作直接强制退出时设置为true

Return: BMXErrorCode

Example:

BMXErrorCode errorCode = client->signOut();

function connectStatus

virtual BMXConnectStatus connectStatus() =0

获取当前和服务器的连接状态

Return: BMXConnectStatus

Example:

function signInStatus

virtual BMXSignInStatus signInStatus() =0

获取当前的登录状态

Return: BMXSignInStatus

Example:

if (client->signInStatus() == BMXSignInStatus::SignIn) {
if (params.size() >= 3 && client->signInStatus() == BMXSignInStatus::SignIn) {
if (params.size() >= 1 && client->signInStatus() == BMXSignInStatus::SignIn) {
if (params.size() >= 2 && client->signInStatus() == BMXSignInStatus::SignIn) {
if (params.size() >= 1 && client->signInStatus() == BMXSignInStatus::SignIn) {
if (params.size() >= 1 && client->signInStatus() == BMXSignInStatus::SignIn) {
if (params.size() >= 2 && client->signInStatus() == BMXSignInStatus::SignIn) {
if (params.size() >= 2 && client->signInStatus() == BMXSignInStatus::SignIn) {

function reconnect

virtual void reconnect() =0

强制重新连接

Example:

function onNetworkChanged

virtual void onNetworkChanged(
    BMXNetworkType type,
    bool reconnect
) =0

处理网络状态发送变化

Parameters:

  • type 变化后的网络类型
  • reconnect 网络是否需要重连

Reimplements: floo::BMXNetworkListener::onNetworkChanged

Example:

function disconnect

virtual void disconnect() =0

断开网络连接

Example:

function changeAppId

virtual BMXErrorCode changeAppId(
    const std::string & appId,
    const std::string & appSecret =""
) =0

更改SDK的appId,本操作会同时更新BMXConfig中的appId。

Parameters:

  • appId 新变更的appId

Return: BMXErrorCode

Example:

function initializeServerConfig

virtual BMXErrorCode initializeServerConfig(
    bool isLocal
) =0

获取app的服务器网络配置,在初始化SDK之后登陆之前调用,可以提前获取服务器配置加快登陆速度。

Parameters:

  • isLocal 为true则使用本地缓存的dns配置,为false则从服务器获取最新的配置。

Return: BMXErrorCode

Example:

function sendMessage

virtual void sendMessage(
    BMXMessagePtr msg
) =0

发送消息,消息状态变化会通过listener通知,在发送群组消息且指定的群组为开启群组已读回执的情况下, 该接口会自动获取群成员列表id并且填充到message config中去,无需客户端自己进行群组成员列表的填充操作。

Parameters:

  • msg 发送的消息

Protected Functions Documentation

Example:

client->sendMessage(msg);

function BMXClient

BMXClient()

Example:


Updated on 2022-01-26 at 17:20:40 +0800

© 2019-2022 美信拓扑 | 官网 该文件修订时间: 2022-09-21 11:43:07

results matching ""

    No results matching ""