Hive SDK 채팅 기능은 Hive SDK 인증 기능을 사용하여 로그인을 하고 PlayerID를 발급받은 사용자(게스트 계정 포함)만 이용할 수 있습니다.
usinghive;Chat.connect((ResultAPIresult)=>{if(result.isSuccess()){// API Call Success}});
#include"HiveChat.h"FHiveChat::Connect(FHiveChatOnResultDelegate::CreateLambda([this](constFHiveResultAPI&Result){if(Result.IsSuccess()){// API Call Success}}));
#include<HIVE_SDK_Plugin/HIVE_CPP.h>usingnamespacehive;Chat::connect([=](ResultAPIconst&result){if(result.isSuccess()){// API Call Success}});
importcom.hive.Chat;importcom.hive.ResultAPI;Chat.connect(object:Chat.ConnectListener{overridefunonResult(result:ResultAPI){if(result.isSuccess){// API Call Success}}})
importcom.hive.Chat;Chat.connect(result->{if(result.isSuccess()){// API Call Success}});
importHIVEServiceChatInterface.connect{resultinifresult.isSuccess{// API Call Success}}
#import "HIVEService.h"[HiveChatconnectWithHandler:^(HIVEResultAPI*result){if(result.isSuccess){// API Call Success}}];
네트워크 상황에 따라 채팅 소켓 서버 연결이 해제되는 경우, 채팅 재연결을 요청할 수 있습니다.
채팅 소켓 서버 연결 해제 후 10분 이내 재연결을 요청하면 바로 이전에 참여한 채널에 자동 입장하도록 시도합니다. 재연결 요청 결과, 입장에 성공한 채널 목록과 실패한 채널 목록을 응답으로 반환합니다.
Note
일시적인 네트워크 단절 상황 혹은 백그라운드(iOS)-포그라운드 전환 시 SDK 내부에서 자동으로 1회에 한하여 네트워크 재연결을 시도합니다.
채팅 재연결을 요청 시에는 Chat 클래스 reconnect 메서드를 호출합니다. 다음은 채팅 재연결을 요청하는 예제 코드입니다.
usinghive;Chat.reconnect((ResultAPIresult,List<String>channelIds,List<String>failChannelIds)=>{if(result.isSuccess()){// API Call Success}});
#include"HiveChat.h"FHiveChat::Reconnect(FHiveChatOnReconnectDelegate::CreateLambda([this](constFHiveResultAPI&Result,constTArray<FString>&ChannelIds,constTArray<FString>&FailChannelIds){if(Result.IsSuccess()){// API Call Success}}));
#include<HIVE_SDK_Plugin/HIVE_CPP.h>usingnamespacehive;Chat::reconnect([=](ResultAPIconst&result,std::vector<std::string>channelIds,std::vector<std::string>failChannelIds){if(result.isSuccess()){// API Call Success}});
importcom.hive.Chat;importcom.hive.ResultAPI;Chat.reconnect(object:Chat.ReconnectListener{overridefunonResult(result:ResultAPI,channelIds:ArrayList<String>,failChannelIds:ArrayList<String>){if(result.isSuccess){// API Call Success}}})
importcom.hive.Chat;Chat.reconnect(result,channelIds,failChannelIds->{if(result.isSuccess()){// API Call Success}});
importHIVEServiceChatInterface.connect{result,channelIds,failChannelIdsinifresult.isSuccess{// API Call Success}}
#import "HIVEService.h"[HiveChatreconnectWithHandler:^(HIVEResultAPI*result,NSArray<NSString*>*channelIds,NSArray<NSString*>*failChannelIds){if(result.isSuccess){// API Call Success}}];
채팅 연결을 해제하려면 Chat 클래스 disconnect() 메서드를 호출합니다. 아래는 채팅 연결을 해제하는 예제 코드입니다.
Note
앱 사용자 계정이 로그아웃하면 채팅 연결 해제 요청을 자동으로 실행합니다.
usinghive;Chat.disconnect((ResultAPIresult)=>{if(result.isSuccess()){// API Call Success}});
#include"HiveChat.h"FHiveChat::Disconnect(FHiveChatOnResultDelegate::CreateLambda([this](constFHiveResultAPI&Result){if(Result.IsSuccess()){// API Call Success}}));
#include<HIVE_SDK_Plugin/HIVE_CPP.h>usingnamespacehive;Chat::disconnect([=](ResultAPIconst&result){if(result.isSuccess()){// API Call Success}});
importcom.hive.Chat;importcom.hive.ResultAPI;Chat.disconnect(object:Chat.DisconnectListener{overridefunonResult(result:ResultAPI){if(result.isSuccess){// API Call Success}}})
importcom.hive.Chat;Chat.disconnect(result->{if(result.isSuccess()){// API Call Success}});
importHIVEServiceChatInterface.disconnect(result){ifresult.isSuccess{// API Call Success}}
#import "HIVEService.h"[HiveChatdisconnectWithHandler:^(HIVEResultAPI*result){if(result.isSuccess){// API Call Success}}];