示例#1
0
        public void AddFrame(ServerFrame f)
        {
            ThreadPool.QueueUserWorkItem((x) =>
            {
                bool notfound = true;
                while (notfound)
                {
                    lock(RegistorSS)
                    {
                        foreach (var i in RegistorSS)
                        {
                            if (i.HandlerID == "none")
                            {
                                i.Name = f.Name;
                                i.Description = f.Name;
                                i.HandlerID = f.HandlerID;

                                byte[] buf = new Handshake() { Description = f.Name, Name = f.Name, HandlerID = f.HandlerID }.Write();

                                i.NetS.Write(buf, 0, buf.Length);
                                Logger.Log("Assigned Role of " + f.HandlerID + " to " + i.ID.ToString());
                                notfound = false;

                                break;
                            }
                        }
                    }
                }
            });
        }
示例#2
0
        public override Packet Parse(byte[] data)
        {
            var ps = new ProticallStream();

            ps.ReadByte(data);

            var re = new Handshake();

            var strl = ps.ReadVarInt(data);
            re.ID = Guid.Parse(ps.ReadString(data, strl));

            strl = ps.ReadVarInt(data);
            re.Name = ps.ReadString(data, strl);

            strl = ps.ReadVarInt(data);
            re.Description = ps.ReadString(data, strl);

            strl = ps.ReadVarInt(data);
            re.HandlerID = ps.ReadString(data, strl);

            return re;
        }