Пример #1
0
        /// <summary>
        /// 点击会话
        /// </summary>
        /// <param name="box">会话控件</param>
        private void click(SessionBox box = null)
        {
            if (id == null)
            {
                id = sessions.OrderBy(i => i.time).Last().id;
            }

            var control = (SessionBox)sceMain.Controls[0].Controls[id];

            if (control == null)
            {
                return;
            }

            control.BackColor = sceMain.Controls[0].BackColor;
            control.Refresh();
            if (box == null)
            {
                box = control;
            }

            box.unRead    = false;
            box.BackColor = Color.White;
            box.Refresh();

            id = box.Name;
            var session = sessions.Find(i => i.id == id);

            session.unRead = false;

            SessionAPI.SetUnreadCountZero(NIMSessionType.kNIMSessionTypeP2P, id, (a, b, c) => { });
            MessagelogAPI.MarkMessagesStatusRead(id, NIMSessionType.kNIMSessionTypeP2P, (a, b, c) => { });
        }
Пример #2
0
        /// <summary>
        /// 加载历史消息
        /// </summary>
        public void showHistory()
        {
            MessagelogAPI.QueryMsglogLocally(targetId, NIMSessionType.kNIMSessionTypeP2P, 20, 0, (code, accountId, sType, result) =>
            {
                var list = result.MsglogCollection;
                if (list == null || list.Length == 0)
                {
                    return;
                }

                messages.Clear();
                foreach (var msg in list.OrderBy(i => i.TimeStamp))
                {
                    addMessage(msg);
                }

                void action() => refresh();

                while (!(Parent?.IsHandleCreated ?? false))
                {
                    Thread.Sleep(100);
                }

                Invoke((Action)action);
            });
        }
Пример #3
0
        private void BtnImport_Click(object sender, EventArgs e)
        {
            NIMLogsBackupImportInfo import_info = new NIMLogsBackupImportInfo();

            import_info.UnPackageCallback_     = ImportBackupFromRemoteUnPackageCallback;
            import_info.RemoteDecryptCallback_ = ImportBackupFromRemoteDecryptCallback;
            import_info.CompleteCallback_      = LogsBackupCompleteCallback;
            import_info.ProgressCallback_      = LogsBackupProgressCallback;
            MessagelogAPI.ImportBackupFromRemote(import_info);
        }
Пример #4
0
        private void BtnExport_Click(object sender, EventArgs e)
        {
            NIMLogsBackupExportInfo export_info = new NIMLogsBackupExportInfo();

            export_info.ToRemotePackageCallback_ = ExportBackupToRemotePackageCallback;
            export_info.ToRemoteEncryptCallback_ = ExportBackupToRemoteEncryptCallback;
            export_info.CompleteCallback_        = LogsBackupCompleteCallback;
            export_info.ProgressCallback_        = LogsBackupProgressCallback;
            string encrypt_key_ = System.Guid.NewGuid().ToString("N");//32位

            export_info.ToRemoteLogFiter_ = ExportBackupToRemoteLogFiterCallback;

            MessagelogAPI.ExportBackupToRemote(export_info, encrypt_key_);
        }
Пример #5
0
        /// <summary>
        /// 查询历史消息
        /// </summary>
        private void getHistory()
        {
            MessagelogAPI.QueryMsglogOnline(targetId, NIMSessionType.kNIMSessionTypeP2P, 6, 0, endTime, 0, false, true, true, (code, accountId, sType, result) =>
            {
                void action()
                {
                    var list = result.MsglogCollection;
                    if (list == null || list.Length == 0)
                    {
                        return;
                    }

                    foreach (var msg in list.OrderByDescending(i => i.TimeStamp))
                    {
                        var message = new NimMessage
                        {
                            id        = msg.ClientMsgID,
                            msgid     = msg.ServerMsgId,
                            from      = msg.SenderID,
                            to        = msg.ReceiverID,
                            type      = msg.MessageType.GetHashCode(),
                            body      = NimUtil.getMsg(msg),
                            direction = msg.SenderID == targetId ? 1 : 0,
                            timetag   = msg.TimeStamp / 1000
                        };

                        addMessage(message);
                    }

                    if (list.Length < 6)
                    {
                        sbeNext.Enabled = false;
                        sbeNext.Text    = "已到达终点";
                        return;
                    }

                    endTime = list.Last().TimeStamp;
                }

                Invoke((Action)action);
            });
        }