Example #1
0
 public override int GetHashCode()
 {
     if (Object.ReferenceEquals(this, null))
     {
         return(0);
     }
     return(Groupname == null ? 0 : Groupname.GetHashCode());
 }
Example #2
0
        public int CompareTo(Group other)
        {
            //1 - текущий объект больше
            //0 - объекты равны
            //-1 - текущий объект меньше

            if (Object.ReferenceEquals(other, null))
            {
                return(1);
            }
            return(Groupname.CompareTo(other.Groupname));
        }
Example #3
0
        private void CreatGroup_Click(object sender, EventArgs e)
        {
            if (num < 2)
            {
                MessageBox.Show("群组人数不能少于2人!");
                return;
            }
            if (Groupname.Text.Length >= 10)
            {
                MessageBox.Show("名字不需要这么长");
                return;
            }
            StreamReader file = new StreamReader(Account_data.DirContacts + "Groups.txt");
            String       line;

            while ((line = file.ReadLine()) != null)
            {
                if (line == Groupname.Text)
                {
                    MessageBox.Show("你这个群名重复了,换一个!");
                    Groupname.Focus();
                    file.Close();
                    Groupname.Clear();
                    return;
                }
            }
            file.Close();

            Group_name = Groupname.Text;
            StreamWriter s = new StreamWriter(Account_data.DirContacts + "Groups.txt", true);

            s.Write(Group_name + "\r\n");
            s.Close();

            if (!File.Exists(Account_data.DirContacts + Group_name + "_G" + ".txt"))
            {
                File.Create(Account_data.DirContacts + Group_name + "_G" + ".txt").Close();
            }


            StreamWriter sw = new StreamWriter(Account_data.DirContacts + Group_name + "_G" + ".txt", true);

            for (int i = 0; i < G.Count; i++)
            {
                sw.Write(G[i].ID + "\r\n");
            }
            sw.Flush();
            sw.Close();
            G.Clear();
            Add_group_panel.Controls.Clear();
            Groupname.Clear();
            this.Close();
        }
Example #4
0
        public int CompareTo(object obj)
        {
            //1 - текущий объект больше
            //0 - объекты равны
            //-1 - текущий объект меньше
            if (obj is null)
            {
                return(1);
            }

            if (obj is Group other)
            {
                return(Groupname.CompareTo(other.Groupname));
            }
            else
            {
                throw new ArgumentException("Object is not a Group");
            }
        }
Example #5
0
        public override bool ProcessReceivedMessage(Nettention.Proud.ReceivedMessage pa, Object hostTag)
        {
            Nettention.Proud.HostID remote = pa.RemoteHostID;
            if (remote == Nettention.Proud.HostID.HostID_None)
            {
                ShowUnknownHostIDWarning(remote);
            }

            Nettention.Proud.Message __msg = pa.ReadOnlyMessage;
            int orgReadOffset = __msg.ReadOffset;

            Nettention.Proud.RmiID __rmiID = Nettention.Proud.RmiID.RmiID_None;
            if (!__msg.Read(out __rmiID))
            {
                goto __fail;
            }

            switch (__rmiID)
            {
            case Common.RequestLogon:
            {
                Nettention.Proud.RmiContext ctx = new Nettention.Proud.RmiContext();
                ctx.sentFrom     = pa.RemoteHostID;
                ctx.relayed      = pa.IsRelayed;
                ctx.hostTag      = hostTag;
                ctx.encryptMode  = pa.EncryptMode;
                ctx.compressMode = pa.CompressMode;

                String Groupname; CardClient.Marshaler.Read(__msg, out Groupname);
                bool   isNewClient; CardClient.Marshaler.Read(__msg, out isNewClient);
                core.PostCheckReadMessage(__msg, RmiName_RequestLogon);
                if (enableNotifyCallFromStub == true)
                {
                    string parameterString = "";
                    parameterString += Groupname.ToString() + ",";
                    parameterString += isNewClient.ToString() + ",";
                    NotifyCallFromStub(Common.RequestLogon, RmiName_RequestLogon, parameterString);
                }

                if (enableStubProfiling)
                {
                    Nettention.Proud.BeforeRmiSummary summary = new Nettention.Proud.BeforeRmiSummary();
                    summary.rmiID   = Common.RequestLogon;
                    summary.rmiName = RmiName_RequestLogon;
                    summary.hostID  = remote;
                    summary.hostTag = hostTag;
                    BeforeRmiInvocation(summary);
                }

                long t0 = Nettention.Proud.PreciseCurrentTime.GetTimeMs();

                // Call this method.
                bool __ret = RequestLogon(remote, ctx, Groupname, isNewClient);

                if (__ret == false)
                {
                    // Error: RMI function that a user did not create has been called.
                    core.ShowNotImplementedRmiWarning(RmiName_RequestLogon);
                }

                if (enableStubProfiling)
                {
                    Nettention.Proud.AfterRmiSummary summary = new Nettention.Proud.AfterRmiSummary();
                    summary.rmiID       = Common.RequestLogon;
                    summary.rmiName     = RmiName_RequestLogon;
                    summary.hostID      = remote;
                    summary.hostTag     = hostTag;
                    summary.elapsedTime = Nettention.Proud.PreciseCurrentTime.GetTimeMs() - t0;
                    AfterRmiInvocation(summary);
                }
            }
            break;

            case Common.RequestClientCount:
            {
                Nettention.Proud.RmiContext ctx = new Nettention.Proud.RmiContext();
                ctx.sentFrom     = pa.RemoteHostID;
                ctx.relayed      = pa.IsRelayed;
                ctx.hostTag      = hostTag;
                ctx.encryptMode  = pa.EncryptMode;
                ctx.compressMode = pa.CompressMode;

                core.PostCheckReadMessage(__msg, RmiName_RequestClientCount);
                if (enableNotifyCallFromStub == true)
                {
                    string parameterString = "";
                    NotifyCallFromStub(Common.RequestClientCount, RmiName_RequestClientCount, parameterString);
                }

                if (enableStubProfiling)
                {
                    Nettention.Proud.BeforeRmiSummary summary = new Nettention.Proud.BeforeRmiSummary();
                    summary.rmiID   = Common.RequestClientCount;
                    summary.rmiName = RmiName_RequestClientCount;
                    summary.hostID  = remote;
                    summary.hostTag = hostTag;
                    BeforeRmiInvocation(summary);
                }

                long t0 = Nettention.Proud.PreciseCurrentTime.GetTimeMs();

                // Call this method.
                bool __ret = RequestClientCount(remote, ctx);

                if (__ret == false)
                {
                    // Error: RMI function that a user did not create has been called.
                    core.ShowNotImplementedRmiWarning(RmiName_RequestClientCount);
                }

                if (enableStubProfiling)
                {
                    Nettention.Proud.AfterRmiSummary summary = new Nettention.Proud.AfterRmiSummary();
                    summary.rmiID       = Common.RequestClientCount;
                    summary.rmiName     = RmiName_RequestClientCount;
                    summary.hostID      = remote;
                    summary.hostTag     = hostTag;
                    summary.elapsedTime = Nettention.Proud.PreciseCurrentTime.GetTimeMs() - t0;
                    AfterRmiInvocation(summary);
                }
            }
            break;

            case Common.RequestMaching:
            {
                Nettention.Proud.RmiContext ctx = new Nettention.Proud.RmiContext();
                ctx.sentFrom     = pa.RemoteHostID;
                ctx.relayed      = pa.IsRelayed;
                ctx.hostTag      = hostTag;
                ctx.encryptMode  = pa.EncryptMode;
                ctx.compressMode = pa.CompressMode;

                core.PostCheckReadMessage(__msg, RmiName_RequestMaching);
                if (enableNotifyCallFromStub == true)
                {
                    string parameterString = "";
                    NotifyCallFromStub(Common.RequestMaching, RmiName_RequestMaching, parameterString);
                }

                if (enableStubProfiling)
                {
                    Nettention.Proud.BeforeRmiSummary summary = new Nettention.Proud.BeforeRmiSummary();
                    summary.rmiID   = Common.RequestMaching;
                    summary.rmiName = RmiName_RequestMaching;
                    summary.hostID  = remote;
                    summary.hostTag = hostTag;
                    BeforeRmiInvocation(summary);
                }

                long t0 = Nettention.Proud.PreciseCurrentTime.GetTimeMs();

                // Call this method.
                bool __ret = RequestMaching(remote, ctx);

                if (__ret == false)
                {
                    // Error: RMI function that a user did not create has been called.
                    core.ShowNotImplementedRmiWarning(RmiName_RequestMaching);
                }

                if (enableStubProfiling)
                {
                    Nettention.Proud.AfterRmiSummary summary = new Nettention.Proud.AfterRmiSummary();
                    summary.rmiID       = Common.RequestMaching;
                    summary.rmiName     = RmiName_RequestMaching;
                    summary.hostID      = remote;
                    summary.hostTag     = hostTag;
                    summary.elapsedTime = Nettention.Proud.PreciseCurrentTime.GetTimeMs() - t0;
                    AfterRmiInvocation(summary);
                }
            }
            break;

            default:
                goto __fail;
            }
            return(true);

__fail:
            {
                __msg.ReadOffset = orgReadOffset;
                return(false);
            }
        }
Example #6
0
 public override int GetHashCode()
 {
     return(Groupname.GetHashCode());
 }