本文整理汇总了C#中db.Database.CheckIp方法的典型用法代码示例。如果您正苦于以下问题:C# Database.CheckIp方法的具体用法?C# Database.CheckIp怎么用?C# Database.CheckIp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Database
的用法示例。
在下文中一共展示了Database.CheckIp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessHelloPacket
private void ProcessHelloPacket(HelloPacket pkt)
{
db = new Database();
//Console.Out.WriteLine(pkt.GUID + ": " + pkt.Password);
if ((account = db.Verify(pkt.GUID, pkt.Password)) == null)
{
Console.WriteLine(@"Account not verified.");
account = Database.CreateGuestAccount(pkt.GUID);
if (account == null)
{
Console.WriteLine(@"Account is null!");
SendPacket(new FailurePacket
{
Message = "Invalid account."
});
Disconnect();
db.Dispose();
return;
}
}
if ((ip = db.CheckIp(skt.RemoteEndPoint.ToString().Split(':')[0])) == null)
{
Console.WriteLine(@"Error checking IP");
SendPacket(new FailurePacket
{
Message = "Error with IP."
});
Disconnect();
db.Dispose();
return;
}
Console.WriteLine(@"Client trying to connect!");
ConnectedBuild = pkt.BuildVersion;
if (!RealmManager.TryConnect(this))
{
if (CheckAccountInUse(account.AccountId) != false)
{
Console.WriteLine(@"Account in use: " + account.AccountId + @" " + account.Name);
account = null;
SendPacket(new FailurePacket
{
Message = "Account in use! Retrying..."
});
Disconnect();
db.Dispose();
return;
}
account = null;
SendPacket(new FailurePacket
{
Message = "Failed to connect."
});
Disconnect();
Console.WriteLine(@"Failed to connect.");
}
else
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(@"Client loading world");
Console.ForegroundColor = ConsoleColor.White;
var world = RealmManager.GetWorld(pkt.GameId);
if (world == null)
{
SendPacket(new FailurePacket
{
Message = "Invalid world."
});
Disconnect();
Console.WriteLine(@"Invalid world");
}
Console.ForegroundColor = ConsoleColor.Yellow;
try
{
Console.WriteLine(@"Client joined world " + world.Id);
}
catch
{
Console.WriteLine(@"Error! World is null");
}
Console.ForegroundColor = ConsoleColor.White;
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();
//.........这里部分代码省略.........
示例2: ProcessHelloPacket
private void ProcessHelloPacket(HelloPacket pkt)
{
if (isGuest)
Disconnect();
db = new Database();
// Console.Out.WriteLine(pkt.GUID + ": " + pkt.Password);
// Console.Out.WriteLine(pkt.GUID + ": " + account.AccountId + @" " + account.Name);
if ((account = db.Verify(pkt.GUID, pkt.Password)) == null)
{
Console.WriteLine(@"Account not verified.");
account = Database.CreateGuestAccount(pkt.GUID);
if (account == null)
{
Console.WriteLine(@"Account is null!");
SendPacket(new FailurePacket
{
Message = "Invalid account."
});
Disconnect();
return;
}
}
if ((ip = db.CheckIp(skt.RemoteEndPoint.ToString().Split(':')[0])) == null)
{
Console.WriteLine(@"Error checking IP");
SendPacket(new FailurePacket
{
Message = "Error with IP."
});
Disconnect();
return;
}
Console.WriteLine(@"Client trying to connect!" + account.AccountId + @" " + account.Name);
ConnectedBuild = pkt.BuildVersion;
if (!RealmManager.TryConnect(this))
{
if (CheckAccountInUse(account.AccountId) != false)
{
Console.WriteLine(@"Account in use: " + account.AccountId + @" " + account.Name);
account = null;
SendPacket(new FailurePacket
{
Message = "Account in use! Retrying..."
});
Disconnect();
return;
}
account = null;
SendPacket(new FailurePacket
{
Message = "Failed to connect."
});
Disconnect();
Console.WriteLine(@"Failed to connect.");
}
else
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(@"Client loading world");
Console.ForegroundColor = ConsoleColor.White;
var world = RealmManager.GetWorld(pkt.GameId);
if (world == null)
{
SendPacket(new FailurePacket
{
Message = "Invalid world, Restart your Client."
});
Disconnect();
Console.WriteLine(@"Invalid world");
}
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(@"Client joined world " + world.Id);
Console.ForegroundColor = ConsoleColor.White;
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;
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
});
stage = ProtocalStage.Handshaked;
}
}