Esempio n. 1
0
        public void Process(EventLoop netloop, Channel c, List <Packet> packets)
        {
            //?
            foreach (var p in packets)
            {
                istream.SetUp(p.body, p.len);


                //byte serverType = istream.ReadByte();
                byte packetType = p.packetType;
                //p.serverType = serverType;
                p.packetType = packetType;
                uint service = istream.ReadUInt32();
                p.serviceId = service;

                byte serverType = Packet.GetServiceServerType(service);

                uint serviceId = Packet.GetServiceId(service);


                Console.WriteLine($"Process Server Type:{serverType},{serviceId}");

                if (_serverType == serverType)
                {
                    //process
                    HandlePacket(netloop, c, p);
                }
                else
                {
                    //router
                    ForwardPacket(netloop, p);

                    //_remoteServer[serverType]?.Forward(p);
                }
            }


            if (_workLoop != netloop)
            {
                _workLoop.AddAsyncJob(() =>
                {
                    //process
                    Packet ret = new Packet();

                    netloop.AddAsyncJob(() =>
                    {
                        //byte[] buff = loop.PWriter.Write("abcde");

                        //c.Send("abcde",loop.PWriter);
                    });
                });
            }
            else
            {
                Packet ret = new Packet();
                //byte[] buff = loop.PWriter.Write("abcde");
                //c.Send(buff);
                //c.Send("abcde",loop.PWriter);
            }
        }
Esempio n. 2
0
        void HandlePacket(EventLoop netloop, Channel c, Packet p)
        {
            if (_workLoop != netloop)
            {
                _workLoop.AddAsyncJob(() =>
                {
                    //byte[] buff = loop.PWriter.Write("abcde");

                    //c.Send("abcde",loop.PWriter);

                    int xx;
                    string bbb;
                    switch (p.serviceId)
                    {
                    case 1:
                        break;

                    default:
                        break;
                    }

                    netloop.AddAsyncJob(() =>
                    {
                        c.Send();
                    });

                    //c.Send()
                });
            }
            else
            {
                Packet ret = new Packet();
                //byte[] buff = loop.PWriter.Write("abcde");
                //c.Send(buff);
                //c.Send("abcde",loop.PWriter);
            }
        }