/// <summary>
        ///
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="tag"></param>
        /// <param name="realtime"></param>
        internal AVIMClient(string clientId, string tag, AVRealtime realtime)
        {
            this.clientId = clientId;
            Tag           = tag ?? tag;
            _realtime     = realtime;

            #region sdk 强制在接收到消息之后一定要向服务端回发 ack
            var ackListener = new AVIMMessageListener();
            ackListener.OnMessageReceived += AckListener_OnMessageReceieved;
            //this.RegisterListener(ackListener);
            #endregion

            #region 默认要为当前 client 绑定一个消息的监听器,用作消息的事件通知
            var messageListener = new AVIMMessageListener();
            messageListener.OnMessageReceived += MessageListener_OnMessageReceived;
            this.RegisterListener(messageListener);
            #endregion

            #region 默认要为当前 client 绑定一个 session close 的监听器,用来监测单点登录冲突的事件通知
            var sessionListener = new SessionListener();
            sessionListener.OnSessionClosed += SessionListener_OnSessionClosed;
            this.RegisterListener(sessionListener);
            #endregion

            #region 默认要为当前 client 监听 Ta 所出的对话中的人员变动的被动消息通知
            var membersJoinedListener = new AVIMMembersJoinListener();
            membersJoinedListener.OnMembersJoined += MembersJoinedListener_OnMembersJoined;
            this.RegisterListener(membersJoinedListener);

            var membersLeftListener = new AVIMMembersLeftListener();
            membersLeftListener.OnMembersLeft += MembersLeftListener_OnMembersLeft;
            this.RegisterListener(membersLeftListener);

            var invitedListener = new AVIMInvitedListener();
            invitedListener.OnInvited += InvitedListener_OnInvited;
            this.RegisterListener(invitedListener);

            var kickedListener = new AVIMKickedListener();
            kickedListener.OnKicked += KickedListener_OnKicked;
            this.RegisterListener(kickedListener);
            #endregion

            #region 当前 client id 离线的时间内,TA 所在的对话产生的普通消息会以离线消息的方式送达到 TA 下一次登录的客户端
            var offlineMessageListener = new OfflineMessageListener();
            offlineMessageListener.OnOfflineMessageReceived += OfflineMessageListener_OnOfflineMessageReceived;
            this.RegisterListener(offlineMessageListener);
            #endregion

            #region 当前 client 离线期间内产生的未读消息可以通过之后调用 Conversation.SyncStateAsync 获取一下离线期间内的未读状态
            var unreadListener = new ConversationUnreadListener();
            this.RegisterListener(unreadListener);
            #endregion
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="tag"></param>
        /// <param name="realtime"></param>
        internal AVIMClient(string clientId, string tag, AVRealtime realtime)
        {
            this.clientId = clientId;
            Tag           = tag ?? tag;
            _realtime     = realtime;

            #region sdk 强制在接收到消息之后一定要向服务端回发 ack
            var ackListener = new AVIMMessageListener();
            ackListener.OnMessageReceived += AckListener_OnMessageReceieved;
            //this.RegisterListener(ackListener);
            #endregion

            #region 默认要为当前 client 绑定一个消息的监听器,用作消息的事件通知
            var messageListener = new AVIMMessageListener();
            messageListener.OnMessageReceived += MessageListener_OnMessageReceived;
            this.RegisterListener(messageListener);
            #endregion

            #region 默认要为当前 client 绑定一个 session close 的监听器,用来监测单点登录冲突的事件通知
            var sessionListener = new SessionListener();
            sessionListener.OnSessionClosed += SessionListener_OnSessionClosed;
            this.RegisterListener(sessionListener);
            #endregion

            #region 默认要为当前 client 监听 Ta 所出的对话中的人员变动的被动消息通知
            var membersJoinedListener = new AVIMMembersJoinListener();
            membersJoinedListener.OnMembersJoined += MembersJoinedListener_OnMembersJoined;
            this.RegisterListener(membersJoinedListener);

            var membersLeftListener = new AVIMMembersLeftListener();
            membersLeftListener.OnMembersLeft += MembersLeftListener_OnMembersLeft;
            this.RegisterListener(membersLeftListener);

            var invitedListener = new AVIMInvitedListener();
            invitedListener.OnInvited += InvitedListener_OnInvited;
            this.RegisterListener(invitedListener);

            var kickedListener = new AVIMKickedListener();
            kickedListener.OnKicked += KickedListener_OnKicked;
            this.RegisterListener(kickedListener);
            #endregion

            #region 当前 client id 离线的时间内,TA 所在的对话产生的普通消息会以离线消息的方式送达到 TA 下一次登录的客户端
            var offlineMessageListener = new OfflineMessageListener();
            offlineMessageListener.OnOfflineMessageReceived += OfflineMessageListener_OnOfflineMessageReceived;
            this.RegisterListener(offlineMessageListener);
            #endregion

            #region 当前 client 离线期间内产生的未读消息可以通过之后调用 Conversation.SyncStateAsync 获取一下离线期间内的未读状态
            var unreadListener = new ConversationUnreadListener();
            this.RegisterListener(unreadListener);
            #endregion

            #region 消息补丁(修改或者撤回)
            var messagePatchListener = new MessagePatchListener();
            messagePatchListener.OnReceived = (messages) =>
            {
                foreach (var message in messages)
                {
                    if (message is AVIMRecalledMessage)
                    {
                        m_OnMessageRecalled?.Invoke(this, new AVIMMessagePatchEventArgs(message));
                    }
                    else
                    {
                        m_OnMessageUpdated?.Invoke(this, new AVIMMessagePatchEventArgs(message));
                    }
                }
            };
            this.RegisterListener(messagePatchListener);
            #endregion

            #region configuration
            CurrentConfiguration = new Configuration()
            {
                AutoRead = true,
            };
            #endregion
        }