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


C# GSPacketIn.ReadBytes方法代码示例

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


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

示例1: HandleRSAKey

 protected void HandleRSAKey(GSPacketIn packet)
 {
     RSAParameters para = new RSAParameters();
     para.Modulus = packet.ReadBytes(128);
     para.Exponent = packet.ReadBytes();
     RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
     rsa.ImportParameters(para);
     SendRSALogin(rsa, _loginKey);
 }
开发者ID:geniushuai,项目名称:DDTank-3.0,代码行数:9,代码来源:FightServerConnector.cs

示例2: HandleLogin

        /// <summary>
        /// 战斗服务器登陆
        /// </summary>
        /// <param name="pkg"></param>
        public void HandleLogin(GSPacketIn pkg)
        {
            byte[] rgb = pkg.ReadBytes();

            string[] temp = Encoding.UTF8.GetString(_rsa.Decrypt(rgb, false)).Split(',');

            if (temp.Length == 2)
            {
                _rsa = null;
                int id = int.Parse(temp[0]);
                //Info = ServerMgr.GetServerInfo(id);
                Strict = false;
            }
            else
            {
                log.ErrorFormat("Error Login Packet from {0}", TcpEndpoint);
                Disconnect();
            }
        }
开发者ID:geniushuai,项目名称:DDTank-3.0,代码行数:23,代码来源:ServerClient.cs

示例3: HandleRSAKey

 protected void HandleRSAKey(GSPacketIn packet)
 {
     RSAParameters para = new RSAParameters();
        // packet.ReadBytes(2);
     para.Modulus = packet.ReadBytes(128);
     para.Exponent = packet.ReadBytes();
     RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
     rsa.ImportParameters(para);
     SendRSALogin(rsa, m_loginKey);
     SendListenIPPort(IPAddress.Parse(GameServer.Instance.Configuration.Ip), GameServer.Instance.Configuration.Port);
 }
开发者ID:vancourt,项目名称:BaseGunnyII,代码行数:11,代码来源:LoginServerConnector.cs

示例4: HandlePacket

        //修改:  Xiaov 
        //时间:  2009-11-9
        //描述:  登陆请求
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            try
            {
                GSPacketIn pkg = packet.Clone();
                pkg.ClearContext();

                if (client.Player == null)
                {
                    int version = packet.ReadInt();
                    int clientType = packet.ReadInt();
                    byte[] tempKey = new byte[8];

                    byte[] src = packet.ReadBytes();
                  
                    //解密
                    try
                    {
                        src = WorldMgr.RsaCryptor.Decrypt(src,false);
                    }
                    catch (ExecutionEngineException e)
                    {
                        client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError"));
                        client.Disconnect();
                        GameServer.log.Error("ExecutionEngineException", e);
                        return 0;
                    }
                    catch (Exception ex)
                    {
                        //防止攻击,如果解密出错,直接断开连接
                        client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError"));
                        client.Disconnect();
                        GameServer.log.Error("RsaCryptor", ex);
                        return 0;
                    }
                    //DateTime date = new DateTime(src[0] * 256 + src[1], src[2], src[3], src[4], src[5], src[6]);
                    //int fms_key = (src[7] << 8) + src[8];
                    //client.SetFsm(fms_key, version);

                    //string edition = GameServer.Instance.Configuration.Edition;
                    string edition = GameServer.Edition;
                    //if (version.ToString() != edition && edition != "0")
                    //{
                    //    client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.EditionError"));
                    //    //client.Out.SendEditionError(LanguageMgr.GetTranslation("UserLoginHandler.EditionError"));
                    //    client.Disconnect();
                    //    return 0;
                    //}
                    for (int i = 0; i < 8; i++)
                    {
                        tempKey[i] = src[i+7];
                    }
                    client.setKey(tempKey);
                
                    string[] temp = Encoding.UTF8.GetString(src, 15, src.Length - 15).Split(',');
                    if (temp.Length == 2)
                    {
                        string user = temp[0];
                        string pass = temp[1];

                        //TimeSpan span = date - DateTime.UtcNow;
                        //if (Math.Abs(span.TotalMinutes) < 5)
                        //{
                        if (!LoginMgr.ContainsUser(user))
                        {
                            bool isFirst = false;
                            BaseInterface inter = BaseInterface.CreateInterface();
                            PlayerInfo cha = inter.LoginGame(user, pass, ref isFirst);

                            if (cha != null && cha.ID != 0)
                            {
                                if (cha.ID == -2)
                                {
                                    //帐号被禁用
                                    client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid"));
                                    client.Disconnect();
                                    return 0;
                                }

                                if (!isFirst)
                                {
                                    client.Player = new GamePlayer(cha.ID,user, client, cha);
                                    LoginMgr.Add(cha.ID, client);
                                    client.Server.LoginServer.SendAllowUserLogin(cha.ID);
                                    client.Version = version;
                                }
                                else
                                {
                                    client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Register"));
                                    client.Disconnect();
                                }
                            }
                            else
                            {
                                //client.Out.SendLoginFailed("用户名密码错误");
                                client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.OverTime"));
                                client.Disconnect();
//.........这里部分代码省略.........
开发者ID:geniushuai,项目名称:DDTank-3.0,代码行数:101,代码来源:UserLoginHandler.cs


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