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


C# Database.isWhitelisted方法代码示例

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


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

示例1: ProcessHelloPacket

        void ProcessHelloPacket(HelloPacket pkt)
        {
            Console.WriteLine("Accepting new client...");
            db0 = new Database();
            if ((account = db0.Verify(pkt.GUID, pkt.Password)) == null)
            {
                Console.WriteLine("Account not verified.");
                account = Database.CreateGuestAccount(pkt.GUID);

                //Database.SaveCharacter(account, Database.CreateCharacter(782, 1));
                 //Database.Register(pkt.GUID, pkt.Password, true);

                if (account == null)
                {
                    Console.WriteLine("Account is null");
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Invalid account."
                    });

                    return;
                }

            }
            if (db0.isWhitelisted(db0.Verify(pkt.GUID, pkt.Password)) == false)
            {
                Console.WriteLine("Not whitelisted account trying to connect.");
                SendPacket(new svrPackets.FailurePacket()
                {
                    Message = "You are not whitelisted!"
                });
                //eventual account ban code (assuming you would punish someone for bypassing the webserver and trying to connect throught a proxy or whatever)
                return;
            }
            if (db0.isBanned(db0.Verify(pkt.GUID, pkt.Password)) == true)
            {
                Console.WriteLine("Banned account trying to connect.");
                SendPacket(new svrPackets.FailurePacket()
                {
                    Message = "Your account is banned!"
                });
                //eventual IP ban code (assuming you would punish someone for bypassing the webserver and trying to connect throught a proxy or whatever)
                return;
            }
            Console.WriteLine("Client trying to connect");
            if (!RealmManager.TryConnect(this))
            {
                if (CheckAccountInUse(account.AccountId) != false)
                {
                    Console.WriteLine("Account in use: " + account.AccountId);
                    account = null;
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Account in use! Retrying..."
                    });
                    Disconnect();
                    return;
                }
                account = null;
                SendPacket(new svrPackets.FailurePacket()
                {
                    Message = "Failed to connect."
                });
                Console.WriteLine("Failed to connect.");
            }
            else
            {
                Console.WriteLine("Client loading world");
                World world = RealmManager.GetWorld(pkt.GameId);
                if (world == null)
                {
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Invalid world."
                    });
                    Console.WriteLine("Invalid world");
                }
                else
                {
                    Console.WriteLine("Client joined world " + world.Id.ToString());
                    if (world.Id == -6) //Test World
                        (world as realm.worlds.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;
                    SendPacket(new MapInfoPacket()
                    {
                        Width = world.Map.Width,
                        Height = world.Map.Height,
                        Name = world.Name,
                        Seed = seed,
                        Background = world.Background,
                        AllowTeleport = world.AllowTeleport,
                        ShowDisplays = world.ShowDisplays,
                        ClientXML = world.ClientXML,
                        ExtraXML = world.ExtraXML
                    });
//.........这里部分代码省略.........
开发者ID:CarlosX,项目名称:rotmg_svr,代码行数:101,代码来源:ClientProcessor.cs

示例2: HandleRequest

        public void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (StreamReader rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            using (var db1 = new Database())
            {

                chrs = new Chars()
                {
                    Characters = new List<Char>() { },
                    NextCharId = 2,
                    MaxNumChars = 1,
                    Account = db1.Verify(query["guid"], query["password"]),
                    Servers = new List<ServerItem>() //leave this list empty for the Oryx Sleeping message
                    {
                        new ServerItem()
                        {
                            Name = "Local",
                            Lat = 22.28,
                            Long = 114.16,
                            DNS = "127.0.0.1",//db.confreader.getservers(false).ToString(), //127.0.0.1, CHANGE THIS TO LET YOUR FRIENDS CONNECT
                            Usage = 0.2,
                            AdminOnly = false
                        }
                        //new ServerItem()
                        //{
                        //    Name = "Admin Realm",
                        //    Lat = 22.28,
                        //    Long = 114.16,
                        //    DNS = "127.0.0.1",
                        //    Usage = 0.2,
                        //    AdminOnly = true
                        //}
                    }
                };
                Account dvh = null;
                if (chrs.Account != null)
                {
                    db1.GetCharData(chrs.Account, chrs);
                    db1.LoadCharacters(chrs.Account, chrs);
                    chrs.News = db1.GetNews(chrs.Account);
                    dvh = chrs.Account;
                    if (db1.getRole(chrs.Account) >= (int)Database.Roles.Moderator)
                    {
                        chrs.Account.Admin = true;
                    }
                }
                else
                {
                    chrs.Account = Database.CreateGuestAccount(query["guid"]);
                    chrs.News = db1.GetNews(null);
                }
                if (dvh != null && db1.isWhitelisted(dvh) == false)
                {
                    chrs = Whitelist.whitelisted;
                }
                if (dvh != null && db1.isBanned(dvh) == true)
                {
                    chrs = new Chars();
                }
                MemoryStream ms = new MemoryStream();
                XmlSerializer serializer = new XmlSerializer(chrs.GetType(), new XmlRootAttribute(chrs.GetType().Name) { Namespace = "" });

                XmlWriterSettings xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Encoding = Encoding.UTF8;
                XmlWriter xtw = XmlWriter.Create(context.Response.OutputStream, xws);
                serializer.Serialize(xtw, chrs, chrs.Namespaces);
            }
        }
开发者ID:lcnvdl,项目名称:rotmg-server,代码行数:72,代码来源:list.cs


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