usinghive;ConnectionHandlerconnectionHandler=newConnectionHandler{OnConnected=()=>{// on connected},OnDisconnected=()=>{// on disconnected},OnReconnectStarted()=>{// on reconnect Started},OnReconnected=(ResultAPIresult,List<String>channelIds,List<String>failChannelIds)=>{// on reconnected}};Chat.addConnectionHandler("UNIQUE_KEY",connectionHandler);// add connection handlerChat.removeConnectionHandler("UNIQUE_KEY");// remove connection handler
#include"HiveChat.h"classConnectionListener:publicFHiveConnectionListener{public:UChatTestView*Owner;ConnectionListener(UChatTestView*InOwner):Owner(InOwner){}virtualvoidonConnected()override{// on connected}virtualvoidonDisconnected()override{// on disconnected}virtualvoidonReconnectStarted()override{// on reconnect Started}virtualvoidonReconnected(constFHiveResultAPI&Result,constTArray<FString>&ChannelIds,constTArray<FString>&FailChannelIds)override{// on reconnected}};FHiveChat::AddConnectionListener("UNIQUE_KEY",newConnectionListener(this));// 添加连接监听器FHiveChat::RemoveConnectionListener("UNIQUE_KEY");// 移除连接监听器
#include<HIVE_SDK_Plugin/HIVE_CPP.h>usingnamespacehive;classConnectionListenerImpl:publicConnectionListener{voidonConnected()override{// on connected}voidonDisconnected()override{// 断开连接时}voidonReconnectStarted()override{// on reconnect Started}voidonReconnected(ResultAPIconst&result,std::vector<std::string>channelIds,std::vector<std::string>failChannelIds)override{// on reconnected}};Chat::addConnectionListener("UNIQUE_KEY",newConnectionListenerImpl());// 添加连接监听器Chat::removeConnectionListener("UNIQUE_KEY");// 移除连接监听器
importcom.hive.Chat;// 添加连接监听器Chat.addConnectionListener("UNIQUE_KEY",object:ConnectionListener{overridefunonConnected(){// 已连接}overridefunonDisconnected(){// 断开连接时}overridefunonReconnectStarted(){// on reconnect started}overridefunonReconnected(result:ResultAPI,channelIds:ArrayList<String>,failChannelIds:ArrayList<String>){// 重新连接时}})// 移除连接监听器Chat.removeConnectionListener("UNIQUE_KEY");
importcom.hive.Chat;// 添加连接监听器Chat.addConnectionListener("UNIQUE_KEY",newChat.ConnectionListener(){@OverridepublicvoidonConnected(){// 已连接}@OverridepublicvoidonDisconnected(){// on disconnected}@OverridepublicvoidonReconnectStarted(){// on reconnect started}@OverridepublicvoidonReconnected(@NonNullResultAPIresult,@NonNullArrayList<String>channelIds,@NonNullArrayList<String>failChannelIds){// on reconnected}});// 移除连接监听器Chat.removeConnectionListener("UNIQUE_KEY");
importHIVEServiceclassChatConnectionListener:HiveChatConnectionDelegate{funconConnected(){// on connected}funconDisconnected(){// on disconnected}funconReconnectStarted(){// on reconnect started}funconReconnected(result:ResultAPI,channelIds:[String],failChannelIds:[String]){// 重新连接时}}ChatInterface.addConnectionListener(uniqueKey:"UNIQUE_KEY",listener:ChatConnectionListener())// 添加连接监听器ChatInterface.removeConnectionListener(uniqueKey:"UNIQUE_KEY")// 移除连接监听器
#import "HIVEService.h"@interfaceChatConnectionListener : NSObject<HiveChatConnectionDelegate>@end@implementationChatConnectionListener-(void)onConnected{// on connected}-(void)onDisconnected{// 断开连接时}-(void)onReconnectStarted{// 重新连接开始}-(void)onReconnectedWithResult:(HIVEResultAPI*)resultchannelIds:(NSArray<NSString*>*)channelIdsfailChannelIds:(NSArray<NSString*>*)failChannelIds{// on reconnected}@end[ChatInterfaceaddConnectionListenerWithUniqueKey:@"UNIQUE_KEY"listener:[[ChatConnectionListeneralloc]init]];// 添加连接监听器[ChatInterfaceremoveConnectionListenerWithUniqueKey:@"UNIQUE_KEY"];// 移除连接监听器
usinghive;UserHandleruserHandler=newUserHandler{OnDirectMessage=(message)=>{// direct message received},OnNoticeMessage=(message)=>{// notice message Received}};Chat.addUserHandler("UNIQUE_KEY",userHandler);// add user handlerChat.removeUserHandler("UNIQUE_KEY");// remove user handler
classUserListener:publicFHiveUserListener{public:UChatTestView*Owner;UserListener(UChatTestView*InOwner):Owner(InOwner){}virtualvoidonDirectMessage(constFHiveDirectMessage&message)override{// direct message received}virtualvoidonNoticeMessage(constFHiveNoticeMessage&message)override{// notice message received}};FHiveChat::AddUserListener("UNIQUE_KEY",newUserListener(this));// 添加用户监听器FHiveChat::RemoveUserListener("UNIQUE_KEY");// 移除用户监听器
#include<HIVE_SDK_Plugin/HIVE_CPP.h>usingnamespacehive;classUserListenerImpl:publicUserListener{voidonDirectMessage(DirectMessageconst&message)override{// direct message received}voidonNoticeMessage(NoticeMessageconst&message)override{// notice message received}};Chat::addUserListener("UNIQUE_KEY",newUserListenerImpl());// 添加用户监听器Chat::removeUserListener("UNIQUE_KEY");// 移除用户监听器
usinghive;CustomDataHandlercustomDataHandler=newCustomDataHandler{OnCustomData=(data)=>{// custom data received}};Chat.addCustomDataHandler("UNIQUE_KEY",customDataHandler);// add custom data handlerChat.removeCustomDataHandler("UNIQUE_KEY");// remove custom data handler
classCustomDataListener:publicFHiveCustomDataListener{public:UChatTestView*Owner;CustomDataListener(UChatTestView*InOwner):Owner(InOwner){}virtualvoidonCustomData(constFStringdata)override{// custom data received}};FHiveChat::AddCustomDataListener("UNIQUE_KEY",newCustomDataListener(this));// 添加自定义数据监听器FHiveChat::RemoveCustomDataListener("UNIQUE_KEY");// 移除自定义数据监听器
#include<HIVE_SDK_Plugin/HIVE_CPP.h>usingnamespacehive;classCustomDataListenerImpl:publicCustomDataListener{voidonCustomData(std::stringconst&data)override{// custom data received}};Chat::addCustomDataListener("UNIQUE_KEY",newCustomDataListenerImpl());// 添加自定义数据监听器Chat::removeCustomDataListener("UNIQUE_KEY");// 移除自定义数据监听器