当前位置: 首页>>代码示例>>C#>>正文


C# PacketReader.UInt16方法代码示例

本文整理汇总了C#中PacketReader.UInt16方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.UInt16方法的具体用法?C# PacketReader.UInt16怎么用?C# PacketReader.UInt16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PacketReader的用法示例。


在下文中一共展示了PacketReader.UInt16方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Connect

        public void Connect()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);

                if (Reader.Byte() == 18)
                {
                    string ID = Reader.Text();
                    string PW = Reader.Text();
                    byte ukn = Reader.Byte(); // 0xff
                    UInt16 ServerID = Reader.UInt16();
                    int lResult = 99;

                    //Console.WriteLine("Id:{0} Pass:{1} ServerID:{2}",ID,PW,ServerID);

                    SRX_Serverinfo SSI = GSList[ServerID];
                    if (SSI != null)
                    {
                        UInt16 myKey = 0;
                        string sReason = "";
                        lock (Program.IPCResultList)
                        {
                            myKey = Program.IPCNewId++;
                        }
                        byte[] rqp = Program.IPCServer.PacketRequestLogin(Program.IPCPort, ID, PW, myKey);
                        Servers.IPCenCode(ref rqp, SSI.code);
                        lock (Program.IPCResultList)
                        {
                            Program.IPCResultList.Add(myKey, new IPCItem());
                            Program.IPCResultList[myKey].resultCode = 0x8000;
                        }
                        Program.IPCServer.Send(SSI.ip, SSI.ipcport, rqp);
                        DateTime tOut = DateTime.Now.AddSeconds(30);
                        while ((tOut >= DateTime.Now) && (Program.IPCResultList[myKey].resultCode == 0x8000) && (client.clientSocket.Connected))
                        {
                            System.Threading.Thread.Sleep(10);
                        }
                        lResult = Program.IPCResultList[myKey].resultCode;
                        sReason = Program.IPCResultList[myKey].banReason;
                        lock (Program.IPCResultList)
                        {
                            Program.IPCResultList[myKey] = null;
                            Program.IPCResultList.Remove(myKey);
                        }
                        rqp = null;
                        //Console.WriteLine("Resultado de login: {0}",lResult);
                        switch (lResult)
                        {
                            case 0:
                                if (SSI.lan_wan)
                                {
                                    client.Send(ConnectSucces(SSI.wan, SSI.port, 1));
                                }
                                else
                                {
                                    client.Send(ConnectSucces(SSI.ip, SSI.port, 1));
                                }
                                return;
                            case 1:
                                if (WrongPassword < 3)
                                {
                                    client.Send(WrongInformation());
                                    WrongPassword++;
                                    return;
                                }
                                else
                                {
                                    client.Disconnect(PacketInformation.Client);
                                    return;
                                }
                            case 2:
                                client.Send(ServerIsFull());
                                client.Disconnect(PacketInformation.Client);
                                return;
                            case 3:
                                client.Send(AllreadyConnected());
                                client.Disconnect(PacketInformation.Client);
                                return;
                            case 4:
                                client.Send(BannedUser(sReason));
                                client.Disconnect(PacketInformation.Client);
                                return;
                            default:
                                if (lResult == 0x8000)
                                {
                                    Console.WriteLine("[IPC] Timeout");
                                }
                                else
                                {
                                    Console.WriteLine("[IPC] Result unknown {0}", lResult);
                                }
                                return;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Fuck No fun.. SSI");
                    }
                }
//.........这里部分代码省略.........
开发者ID:CarlosX,项目名称:DarkEmu,代码行数:101,代码来源:Function_Connect.cs


注:本文中的PacketReader.UInt16方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。