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


C# Database.CreateGuestAccount方法代码示例

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


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

示例1: ProcessHelloPacket

        private void ProcessHelloPacket(HelloPacket pkt)
        {
            Database = new Database();
            if ((Account = Database.Verify(pkt.GUID, pkt.Password)) == null)
            {
                Logger.Warn("Account not verified");
                Account = Database.CreateGuestAccount(pkt.GUID);

                if (Account == null)
                {
                    Logger.Warn("Account is null");
                    SendPacket(new FailurePacket
                    {
                        Message = "Invalid account."
                    });
                    Disconnect();
                    Database.Dispose();
                    return;
                }
            }
            if ((IP = Database.CheckIp(Socket.RemoteEndPoint.ToString().Split(':')[0])) == null)
            {
                Logger.Error("Error checking IP");
                SendPacket(new FailurePacket
                {
                    Message = "Error with IP."
                });
                Disconnect();
                Database.Dispose();
                return;
            }
            Logger.Info("Client trying to connect");
            ConnectedBuild = pkt.BuildVersion;
            if (!RealmManager.TryConnect(this))
            {
                if (CheckAccountInUse(Account.AccountId))
                {
                    Logger.Warn($"Account in use: {Account.Name} ({Account.AccountId})");
                    Account = null;
                    SendPacket(new FailurePacket
                    {
                        Message = "Account in use! Retrying..."
                    });
                    Disconnect();
                    Database.Dispose();
                    return;
                }
                Account = null;
                SendPacket(new FailurePacket
                {
                    Message = "Failed to connect."
                });
                Disconnect();
                Logger.Error("Failed to connect");
            }
            else
            {
                Logger.Info("Client loading world");
                var world = RealmManager.GetWorld(pkt.GameId);
                if (world == null)
                {
                    SendPacket(new FailurePacket
                    {
                        Message = "Invalid world."
                    });
                    Disconnect();
                    Logger.Error("Invalid world");
                }
                try
                {
                    Logger.Info($"Client joined world {world.Id}");
                }
                catch
                {
                    Logger.Error("Error, world is null");
                }
                if (world.Id == -6) //Test World
                    (world as Test).LoadJson(pkt.MapInfo);
                else if (world.IsLimbo)
                    world = world.GetInstance(this);
                var seed = (uint)((long)Environment.TickCount * pkt.GUID.GetHashCode()) % uint.MaxValue;
                Random = new wRandom(seed);
                targetWorld = world.Id;
                if (!ConnectedBuildStartsWith(clientVer))
                {
                    SendPacket(new TextPacket
                    {
                        BubbleTime = 1,
                        Stars = -1,
                        Name = "",
                        Text = "Your client is outdated. Visit http://forum.zerorealms.com to get the latest one!"
                    });
                    Disconnect();
                    /*SendPacket(new TextBoxPacket
                    {
                        Button1 = "Okay",
                        Message = "Your client is outdated, Click <font color=\"white\"><b><a href='http://forum.zerorealms.com'>Here</a></b></font> to get the latest one!",
                        Title = "Outdated Client!",
                        Type = "NewClient"
                    });*/
//.........这里部分代码省略.........
开发者ID:BlackRayquaza,项目名称:PhoenixRealms,代码行数:101,代码来源:ClientProcessor.cs


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