usinghive;DirectMessageHandlerdirectMessageHandler=newDirectMessageHandler{OnDirectMessage=(message)=>{// direct message received}};Chat.addDirectMessageHandler("UNIQUE_KEY",directMessageHandler);// add direct message handlerChat.removeDirectMessageHandler("UNIQUE_KEY");// remove direct message handler
classDirectMessageListener:publicFHiveDirectMessageListener{public:UChatTestView*Owner;DirectMessageListener(UChatTestView*InOwner):Owner(InOwner){}virtualvoidonDirectMessage(constFHiveDirectMessage&message)override{// direct message received}};FHiveChat::AddDirectMessageListener("UNIQUE_KEY",newDirectMessageListener(this));// add direct message listenerFHiveChat::RemoveDirectMessageListener("UNIQUE_KEY");// remove direct message listener
#include<HIVE_SDK_Plugin/HIVE_CPP.h>usingnamespacehive;classDirectMessageListenerImpl:publicDirectMessageListener{voidonDirectMessage(DirectMessageconst&message)override{// direct message received}};Chat::addDirectMessageListener("UNIQUE_KEY",newDirectMessageListenerImpl());// add direct message listenerChat::removeDirectMessageListener("UNIQUE_KEY");// remove direct message listener
importcom.hive.Chat;// add direct message listenerChat.addDirectMessageListener("UNIQUE_KEY",object:Chat.DirectMessageListener{overridefunonDirectMessage(message:Chat.DirectMessage){// direct message received}})// remove direct message listenerChat.removeDirectMessageListener("UNIQUE_KEY");
importcom.hive.Chat;// add direct message listenerChat.addDirectMessageListener("UNIQUE_KEY",newChat.DirectMessageListener(){@OverridepublicvoidonDirectMessage(@NonNullChat.DirectMessagemessage){// direct message received}});// remove direct message listenerChat.removeDirectMessageListener("UNIQUE_KEY");
importHIVEServiceclassChatDirectMessageListener:HiveChatDirectMessageDelegate{funconDirectMessage(_message:Chat.DirectMessage){// direct message received}}ChatInterface.addDirectMessageListener(uniqueKey:"UNIQUE_KEY",listener:ChatDirectMessageListener())// add direct message listenerChatInterface.removeDirectMessageListener(uniqueKey:"UNIQUE_KEY")// remove direct message listener
#import "HIVEService.h"@interfaceChatDirectMessageListener : NSObject<HiveChatDirectMessageDelegate>@end@implementationChatDirectMessageListener-(void)onDirectMessage:(Chat.DirectMessage*)message{// direct message received}@end[ChatInterfaceaddDirectMessageListenerWithUniqueKey:@"UNIQUE_KEY"listener:[[ChatDirectMessageListeneralloc]init]];// add direct message listener[ChatInterfaceremoveDirectMessageListenerWithUniqueKey:@"UNIQUE_KEY"];// remove direct message listener