示例#1
0
        public void Init()
        {
            string appID = _context.GetString(Resource.String.agora_app_id);

            _myRtmClientListener = new RtmClientListener();
            _myRtmClientListener.MessageReceived += OnRtmMessageReceived;
            _myRtmClientListener.StateChanged    += OnStateChanged;

            try
            {
                _rtmClient = RtmClient.CreateInstance(_context, appID, _myRtmClientListener);

#if DEBUG
                _rtmClient.SetParameters("{\"rtm.log_filter\": 65535}");
#endif
            }
            catch (Exception e)
            {
                throw new Exception($"NEED TO check rtm sdk init fatal error\n {e.StackTrace}");
            }

            _callManager = _rtmClient.RtmCallManager;
            _callManager.RemoteInvitationReceived      += RemoteInvitationReceived;
            _callManager.RemoteInvitationFailure       += RemoteInvitationFailure;
            _callManager.LocalInvitationReceivedByPeer += LocalInvitationReceivedByPeer;
            _callManager.RemoteInvitationAccepted      += RemoteInvitationAccepted;
            _callManager.RemoteInvitationRefused       += RemoteInvitationRefused;
            _callManager.LocalInvitationRefused        += LocalInvitationRefused;
            _callManager.LocalInvitationAccepted       += LocalInvitationAccepted;
        }
示例#2
0
 void OnJoinSuccessHandler2(int id)
 {
     Debug.Log("client2  OnJoinSuccess --- id = " + id);
     rtmCallEventHandler = new RtmCallEventHandler();
     rtmCallEventHandler.OnLocalInvitationReceivedByPeer = OnLocalInvitationReceivedByPeerHandler;
     rtmCallEventHandler.OnRemoteInvitationReceived      = OnRemoteInvitationReceivedHandler;
     rtmCallManager  = rtmClient.GetRtmCallManager(rtmCallEventHandler);
     localInvitation = rtmCallManager.CreateLocalCallInvitation("222");
     rtmCallManager.SendLocalInvitation(localInvitation);
     localInvitation.SetChannelId("1212");
     localInvitation.SetContent("23232");
 }
示例#3
0
        // Start is called before the first frame update
        void Start()
        {
            clientEventHandler  = new RtmClientEventHandler();
            channelEventHandler = new RtmChannelEventHandler();
            callEventHandler    = new RtmCallEventHandler();

            rtmClient = new RtmClient(appId, clientEventHandler);
#if UNITY_EDITOR
            rtmClient.SetLogFile("./rtm_log.txt");
#endif

            clientEventHandler.OnQueryPeersOnlineStatusResult = OnQueryPeersOnlineStatusResultHandler;
            clientEventHandler.OnLoginSuccess            = OnClientLoginSuccessHandler;
            clientEventHandler.OnLoginFailure            = OnClientLoginFailureHandler;
            clientEventHandler.OnMessageReceivedFromPeer = OnMessageReceivedFromPeerHandler;

            channelEventHandler.OnJoinSuccess     = OnJoinSuccessHandler;
            channelEventHandler.OnJoinFailure     = OnJoinFailureHandler;
            channelEventHandler.OnLeave           = OnLeaveHandler;
            channelEventHandler.OnMessageReceived = OnChannelMessageReceivedHandler;

            // Optional, tracking members
            channelEventHandler.OnGetMembers         = OnGetMembersHandler;
            channelEventHandler.OnMemberCountUpdated = OnMemberCountUpdatedHandler;
            channelEventHandler.OnMemberJoined       = OnMemberJoinedHandler;
            channelEventHandler.OnMemberLeft         = OnMemberLeftHandler;

            // image
            clientEventHandler.OnImageMessageReceivedFromPeer = OnImageMessageReceivedFromPeerHandler;
            clientEventHandler.OnImageMediaUploadResult       = OnImageMediaUploadResultHandler;
            clientEventHandler.OnSendMessageResult            = OnSendMessageResultHandler;
            clientEventHandler.OnMediaDownloadToFileResult    = OnMediaDownloadToFileResultHandler;
            clientEventHandler.OnMediaDownloadToMemoryResult  = OnMediaDownloadToMemoryResultHandler;

            // invite
            callEventHandler.OnLocalInvitationAccepted       = OnLocalInvitationAcceptedHandler;
            callEventHandler.OnLocalInvitationCanceled       = OnLocalInvitationCanceledHandler;
            callEventHandler.OnLocalInvitationFailure        = OnLocalInvitationFailureHandler;
            callEventHandler.OnLocalInvitationReceivedByPeer = OnLocalInvitationReceivedByPeerHandler;
            callEventHandler.OnLocalInvitationRefused        = OnLocalInvitationRefusedHandler;

            callEventHandler.OnRemoteInvitationAccepted = OnRemoteInvitationAcceptedHandler;
            callEventHandler.OnRemoteInvitationCanceled = OnRemoteInvitationCanceledHandler;
            callEventHandler.OnRemoteInvitationFailure  = OnRemoteInvitationFailureHandler;
            callEventHandler.OnRemoteInvitationReceived = OnRemoteInvitationReceivedHandler;
            callEventHandler.OnRemoteInvitationRefused  = OnRemoteInvitationRefusedHandler;

            callManager = rtmClient.GetRtmCallManager(callEventHandler);
            // state
            clientEventHandler.OnConnectionStateChanged = OnConnectionStateChangedHandler;

            bool initialized = ShowDisplayTexts();
            if (initialized)
            {
                string ver = RtmClient.GetSdkVersion();
                messageDisplay.AddTextToDisplay("RTM version " + ver + " initialized.", Message.MessageType.Info);
            }
            else
            {
                messageDisplay.AddTextToDisplay("RTM not initialized", Message.MessageType.Info);
            }
        }