Exemplo n.º 1
0
        /// <summary>
        /// 加入群组
        /// </summary>
        /// <param name="group"></param>
        /// <param name="inviter"></param>
        /// <param name="inviteMessage"></param>
        private void onAutoAcceptInvitationFromGroup(EMGroup group, string inviter, string inviteMessage)
        {
            EMConversation    conversation = EaseHelper.shard.client.getChatManager().conversationWithType(group.groupId(), EMConversationType.GROUPCHAT, true);
            EMTextMessageBody body         = new EMTextMessageBody("你加入了群聊");
            EMMessage         message      = EMMessage.createSendMessage(SettingMenager.shard.userID, group.groupId(), body, EMChatType.GROUP);

            conversation.insertMessage(message);
            MainFrm main = (MainFrm)Application.OpenForms["MainFrm"];

            if (main == null)
            {
                return;
            }
            main.refreshGroupInfo(group.groupId());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 好友添加成功
        /// </summary>
        /// <param name="user"></param>
        private void onContactAdded(string user)
        {
            AudioPlayer.shard.playTips();
            EMConversation    conversation = EaseHelper.shard.client.getChatManager().conversationWithType(user, EMConversationType.CHAT, true);
            EMTextMessageBody body         = new EMTextMessageBody("我们成为了好友");
            EMMessage         message      = EMMessage.createSendMessage(SettingMenager.shard.userID, user, body, EMChatType.GROUP);

            conversation.insertMessage(message);
            MainFrm main = (MainFrm)Application.OpenForms["MainFrm"];

            if (main == null)
            {
                return;
            }
            main.refreshFriendFromServer();
        }
Exemplo n.º 3
0
        private void Form_oked(string obj)
        {
            int type = 0;

            if (dSkinRadioButton1.Checked)
            {
                type = 2;
            }
            else if (dSkinRadioButton2.Checked)
            {
                type = 1;
            }
            CreateGroupSendModel model = new CreateGroupSendModel();

            model.group_name     = dSkinTextBox1.Text;
            model.group_portrait = "pc_defalt_group_photo.jpg";
            model.group_type     = type;
            HttpUitls.Instance.get <CreateGroupReciveModel>("group/create", model, (json) =>
            {
                if (json.code == 200)
                {
                    EaseHelper.shard.createdGroupId = json.data;
                    AddGroupUserSendModel addGroup  = new AddGroupUserSendModel();
                    addGroup.group_id       = json.data;
                    addGroup.group_user_ids = obj;
                    HttpUitls.Instance.get <BaseReciveModel>("groupUser/addBatch", addGroup, (js) =>
                    {
                        if (js.code == 200)
                        {
                            GroupInfoSendModel m = new GroupInfoSendModel();
                            m.group_id           = json.data;
                            HttpUitls.Instance.get <GroupInfoReciveModel>("group/detail", m, (jso) =>
                            {
                                if (js.code == 200)
                                {
                                    EMConversation conversation = EaseHelper.shard.client.getChatManager().conversationWithType(json.data, EMConversationType.GROUPCHAT, true);
                                    EMTextMessageBody body      = new EMTextMessageBody("你创建了群聊");
                                    EMMessage message           = EMMessage.createSendMessage(SettingMenager.shard.userID, json.data, body, EMChatType.GROUP);
                                    conversation.insertMessage(message);
                                    DBHelper.Instance.addGroupAndFocus(jso.data);
                                    ThreadPool.QueueUserWorkItem(getGroupMembers, json.data);
                                    MainFrm main = (MainFrm)Application.OpenForms["MainFrm"];
                                    if (main != null)
                                    {
                                        main.refreshConversationList();
                                    }
                                    this.BeginInvoke(new EventHandler((s, e) =>
                                    {
                                        this.Close();
                                    }));
                                }
                                else
                                {
                                    if (js.message.Contains("重新登录"))
                                    {
                                        MainFrm main = (MainFrm)Application.OpenForms["MainFrm"];
                                        if (main != null)
                                        {
                                            main.gotoLogin();
                                        }
                                    }
                                }
                            }, (s) =>
                            {
                                if (s < 503 && s > 500)
                                {
                                    MainFrm main = (MainFrm)Application.OpenForms["MainFrm"];
                                    if (main != null)
                                    {
                                        main.gotoLogin();
                                    }
                                }
                            });
                        }
                        else
                        {
                            if (js.message.Contains("重新登录"))
                            {
                                MainFrm main = (MainFrm)Application.OpenForms["MainFrm"];
                                if (main != null)
                                {
                                    main.gotoLogin();
                                }
                            }
                        }
                    }, (code) =>
                    {
                        if (code < 503 && code > 500)
                        {
                            MainFrm main = (MainFrm)Application.OpenForms["MainFrm"];
                            if (main != null)
                            {
                                main.gotoLogin();
                            }
                        }
                    });
                }
                else
                {
                    if (json.message.Contains("重新登录"))
                    {
                        MainFrm main = (MainFrm)Application.OpenForms["MainFrm"];
                        if (main != null)
                        {
                            main.gotoLogin();
                        }
                    }
                }
            }, (code) =>
            {
                if (code < 503 && code > 500)
                {
                    MainFrm main = (MainFrm)Application.OpenForms["MainFrm"];
                    if (main != null)
                    {
                        main.gotoLogin();
                    }
                }
            });
        }