private void JoinChannelBlock(AgoraRtmJoinChannelErrorCode errorCode)
        {
            var success = errorCode == AgoraRtmJoinChannelErrorCode.Ok;

            OnJoinChannel?.Invoke(success);
            if (success)
            {
                Console.WriteLine($"RTM join channel successsful");
            }
            else
            {
                Console.WriteLine($"RTM join channel error: {errorCode}");
            }
        }
Ejemplo n.º 2
0
        public void JoinChannel(string channel)
        {
            Log($"Joining to channel [{channel}]");
            _channelListener = new AgoraRtmChannelListener();
            _channelListener.OnSignalReceived += (signal) =>
            {
                Log($"Signal received from {signal.RtcPeerId}");
                OnSignalReceived?.Invoke(signal);
            };
            _sendMessageChannelCallback = new ResultCallback();
            _sendMessageChannelCallback.OnSuccessAction += (obj) =>
            {
                Log("Send channel message Success");
                OnSendMessage?.Invoke(true);
            };
            _sendMessageChannelCallback.OnFailureAction += (obj) =>
            {
                Log("Send channel message Fail");
                OnSendMessage?.Invoke(false);
            };
            _rtmChannel = _rtmClient.CreateChannel(channel, _channelListener);
            var channelJoinCallBack = new ResultCallback();

            channelJoinCallBack.OnSuccessAction += (obj) =>
            {
                Log("Join Success");
                if (_rtmChannel == null)
                {
                    return;
                }
                OnJoinChannel?.Invoke(true);
            };
            channelJoinCallBack.OnFailureAction += (err) =>
            {
                Log($"Join Fail. {err.ErrorDescription}");
                if (_rtmChannel == null)
                {
                    return;
                }
                OnJoinChannel?.Invoke(false);
            };
            _rtmChannel?.Join(channelJoinCallBack);
        }