Пример #1
0
        private void P2PChannelReport(bool open, string destUserID)
        {
            P2PChannelReportContract contract = new P2PChannelReportContract(destUserID);
            int messageType = open ? this.groupInfoTypes.P2PChannelOpen : this.groupInfoTypes.P2PChannelClose;

            this.rapidPassiveEngine.CustomizeOutter.Send(messageType, CompactPropertySerializer.Default.Serialize(contract));
        }
Пример #2
0
        public void HandleInformation(string sourceUserID, int informationType, byte[] information)
        {
            if (informationType == this.groupInfoTypes.P2PChannelOpen)
            {
                P2PChannelReportContract contract = CompactPropertySerializer.Default.Deserialize <P2PChannelReportContract>(information, 0);
                this.p2PChannelManager.Register(sourceUserID, contract.DestUserID);
                return;
            }

            if (informationType == this.groupInfoTypes.P2PChannelClose)
            {
                P2PChannelReportContract contract = CompactPropertySerializer.Default.Deserialize <P2PChannelReportContract>(information, 0);
                this.p2PChannelManager.Unregister(sourceUserID, contract.DestUserID);
                return;
            }

            if (informationType == this.groupInfoTypes.Join)
            {
                GroupContract contract = CompactPropertySerializer.Default.Deserialize <GroupContract>(information, 0);
                this.dynamicGroupManager.JoinGroup(contract.GroupID, sourceUserID);
                return;
            }

            if (informationType == this.groupInfoTypes.DestroyGroup)
            {
                GroupContract contract = CompactPropertySerializer.Default.Deserialize <GroupContract>(information, 0);
                this.dynamicGroupManager.DestroyGroup(sourceUserID, contract.GroupID);
                return;
            }

            if (informationType == this.groupInfoTypes.QuitGroup)
            {
                GroupContract contract = CompactPropertySerializer.Default.Deserialize <GroupContract>(information, 0);
                this.dynamicGroupManager.QuitGroup(contract.GroupID, sourceUserID);
                return;
            }

            if (informationType == this.groupInfoTypes.Fire)
            {
                RecruitOrFireContract contract = CompactPropertySerializer.Default.Deserialize <RecruitOrFireContract>(information, 0);
                this.dynamicGroupManager.QuitGroup(contract.GroupID, contract.MemberID);
                return;
            }

            if (informationType == this.groupInfoTypes.Broadcast || informationType == this.groupInfoTypes.BroadcastByServer)
            {
                bool transfer = informationType == this.groupInfoTypes.BroadcastByServer;
                BroadcastContract contract = CompactPropertySerializer.Default.Deserialize <BroadcastContract>(information, 0);
                string            groupID  = contract.GroupID;
                if (this.BroadcastReceived != null)
                {
                    this.BroadcastReceived(sourceUserID, groupID, contract.InformationType, contract.Content);
                }

                List <string> members = this.dynamicGroupManager.GetGroupMembers(groupID);
                if (members != null)
                {
                    foreach (string memberID in members)
                    {
                        bool useP2PChannel = transfer ? false : this.p2PChannelManager.IsP2PChannelExist(sourceUserID, memberID);
                        if (memberID != sourceUserID && !useP2PChannel)
                        {
                            this.customizeController.Send(memberID, informationType, information, true, contract.ActionTypeOnChannelIsBusy);
                        }
                    }
                }
                return;
            }
            if (informationType == this.groupInfoTypes.BroadcastBlob || informationType == this.groupInfoTypes.BroadcastBlobByServer)
            {
                BlobFragmentContract contract = CompactPropertySerializer.Default.Deserialize <BlobFragmentContract>(information, 0);
                if (this.BroadcastReceived != null)
                {
                    Information info = this.blobReceiver.Receive(sourceUserID, contract.DestUserID, contract);
                    if (info != null)
                    {
                        this.BroadcastReceived(sourceUserID, contract.DestUserID, info.InformationType, info.Content);
                    }
                }

                bool          transfer = informationType == this.groupInfoTypes.BroadcastBlobByServer;
                List <string> members  = this.dynamicGroupManager.GetGroupMembers(contract.DestUserID);
                if (members != null)
                {
                    foreach (string memberID in members)
                    {
                        bool useP2PChannel = transfer ? false : this.p2PChannelManager.IsP2PChannelExist(sourceUserID, memberID);
                        if (memberID != sourceUserID && !useP2PChannel)
                        {
                            this.customizeController.Send(memberID, informationType, information, true, ActionTypeOnChannelIsBusy.Continue);
                        }
                    }
                }
                return;
            }
        }