示例#1
0
 public void SendSystemNotify(string title, string content)
 {
     SystemNotifyContract contract = new SystemNotifyContract(title, content, "", null);
     byte[] info = ESPlus.Serialization.CompactPropertySerializer.Default.Serialize(contract);
     foreach (string userID in this.rapidServerEngine.UserManager.GetOnlineUserList())
     {
         this.rapidServerEngine.CustomizeController.Send(userID, InformationTypes.SystemNotify4AllOnline, info);
     }
 }
示例#2
0
        public void SendSystemNotify(string title, string content)
        {
            SystemNotifyContract contract = new SystemNotifyContract(title, content, "", null);

            byte[] info = ESPlus.Serialization.CompactPropertySerializer.Default.Serialize(contract);
            foreach (string userID in this.rapidServerEngine.UserManager.GetOnlineUserList())
            {
                this.rapidServerEngine.CustomizeController.Send(userID, InformationTypes.SystemNotify4AllOnline, info);
            }
        }
 private void btnSend_Click(object sender, EventArgs e)
 {
     try
     {
         SystemNotifyContract contract = new SystemNotifyContract(this.skinTextBox_id.SkinTxt.Text, this.richTextBox1.Text, this.rapidPassiveEngine.CurrentUserID, this.skinTextBox_groupID.SkinTxt.Text);
         byte[] data = CompactPropertySerializer.Default.Serialize(contract);
         int infoType = this.skinRadioButton_group.Checked ? InformationTypes.SystemNotify4Group : InformationTypes.SystemNotify4AllOnline;
         this.rapidPassiveEngine.CustomizeOutter.Send(infoType, data);
         MessageBox.Show("发送成功!");
         this.Close();
     }
     catch (Exception ee)
     {
         MessageBox.Show("发送失败!" + ee.Message);
     }
 }
        /// <summary>
        /// 处理来自客户端的消息。
        /// </summary>
        public void HandleInformation(string sourceUserID, int informationType, byte[] info)
        {
            if (informationType == InformationTypes.AddFriendCatalog)
            {
                string catalogName = System.Text.Encoding.UTF8.GetString(info);
                this.globalCache.AddFriendCatalog(sourceUserID, catalogName);
                return;
            }

            if (informationType == InformationTypes.RemoveFriendCatalog)
            {
                string catalogName = System.Text.Encoding.UTF8.GetString(info);
                this.globalCache.RemoveFriendCatalog(sourceUserID, catalogName);
                return;
            }

            if (informationType == InformationTypes.ChangeFriendCatalogName)
            {
                ChangeCatalogContract contract = CompactPropertySerializer.Default.Deserialize <ChangeCatalogContract>(info, 0);
                this.globalCache.ChangeFriendCatalogName(sourceUserID, contract.OldName, contract.NewName);
                return;
            }

            if (informationType == InformationTypes.MoveFriendToOtherCatalog)
            {
                MoveFriendToOtherCatalogContract contract = CompactPropertySerializer.Default.Deserialize <MoveFriendToOtherCatalogContract>(info, 0);
                this.globalCache.MoveFriend(sourceUserID, contract.FriendID, contract.OldCatalog, contract.NewCatalog);
                return;
            }

            if (informationType == InformationTypes.GetOfflineMessage)
            {
                this.SendOfflineMessage(sourceUserID);
                return;
            }

            if (informationType == InformationTypes.GetOfflineFile)
            {
                this.offlineFileController.SendOfflineFile(sourceUserID);
                return;
            }

            if (informationType == InformationTypes.QuitGroup)
            {
                string groupID = System.Text.Encoding.UTF8.GetString(info);
                this.globalCache.QuitGroup(sourceUserID, groupID);
                //通知其它组成员
                this.rapidServerEngine.ContactsController.Broadcast(groupID, BroadcastTypes.SomeoneQuitGroup, System.Text.Encoding.UTF8.GetBytes(sourceUserID), null, ESFramework.ActionTypeOnChannelIsBusy.Continue);

                return;
            }

            if (informationType == InformationTypes.DeleteGroup)
            {
                string groupID = System.Text.Encoding.UTF8.GetString(info);
                //通知其它组成员
                this.rapidServerEngine.ContactsController.Broadcast(groupID, BroadcastTypes.GroupDeleted, System.Text.Encoding.UTF8.GetBytes(sourceUserID), null, ESFramework.ActionTypeOnChannelIsBusy.Continue);
                this.globalCache.DeleteGroup(groupID);
                return;
            }

            if (informationType == InformationTypes.RemoveFriend)
            {
                string friendID = System.Text.Encoding.UTF8.GetString(info);
                this.globalCache.RemoveFriend(sourceUserID, friendID);
                //通知好友
                this.rapidServerEngine.CustomizeController.Send(friendID, InformationTypes.FriendRemovedNotify, System.Text.Encoding.UTF8.GetBytes(sourceUserID));
                return;
            }

            if (informationType == InformationTypes.ChangeStatus)
            {
                GGUser user      = this.globalCache.GetUser(sourceUserID);
                int    newStatus = BitConverter.ToInt32(info, 0);
                user.UserStatus = (UserStatus)newStatus;
                List <string>             contacts = this.globalCache.GetAllContacts(sourceUserID);
                UserStatusChangedContract contract = new UserStatusChangedContract(sourceUserID, newStatus);
                byte[] msg = ESPlus.Serialization.CompactPropertySerializer.Default.Serialize(contract);
                foreach (string friendID in contacts)
                {
                    this.rapidServerEngine.CustomizeController.Send(friendID, InformationTypes.UserStatusChanged, msg);
                }
                return;
            }

            if (informationType == InformationTypes.SystemNotify4AllOnline)
            {
                foreach (string userID in this.rapidServerEngine.UserManager.GetOnlineUserList())
                {
                    this.rapidServerEngine.CustomizeController.Send(userID, InformationTypes.SystemNotify4AllOnline, info);
                }
                return;
            }

            if (informationType == InformationTypes.SystemNotify4Group)
            {
                SystemNotifyContract contract = CompactPropertySerializer.Default.Deserialize <SystemNotifyContract>(info, 0);
                GGGroup group = this.globalCache.GetGroup(contract.GroupID);
                if (group != null)
                {
                    foreach (string userID in group.MemberList)
                    {
                        this.rapidServerEngine.CustomizeController.Send(userID, InformationTypes.SystemNotify4Group, info);
                    }
                }
                return;
            }
        }