本文整理汇总了C#中Chraft.Net.Client.CheckUsername方法的典型用法代码示例。如果您正苦于以下问题:C# Client.CheckUsername方法的具体用法?C# Client.CheckUsername怎么用?C# Client.CheckUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chraft.Net.Client
的用法示例。
在下文中一共展示了Client.CheckUsername方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePacketLoginRequest
public static void HandlePacketLoginRequest(Client client, LoginRequestPacket packet)
{
if (!client.CheckUsername(packet.Username))
client.Kick("Inconsistent username");
else if (packet.ProtocolOrEntityId < ProtocolVersion)
client.Kick("Outdated client");
else
{
if (client.Server.UseOfficalAuthentication)
{
try
{
string authenticated = Http.GetHttpResponse(new Uri(String.Format("http://www.minecraft.net/game/checkserver.jsp?user={0}&serverId={1}", packet.Username, client.Server.ServerHash)));
if (authenticated != "YES")
{
client.Kick("Authentication failed");
return;
}
}
catch (Exception exc)
{
client.Kick("Error while authenticating...");
client.Logger.Log(exc);
return;
}
}
Task.Factory.StartNew(client.SendLoginSequence);
}
}
示例2: HandlePacketHandshake
public static void HandlePacketHandshake(Client client, HandshakePacket packet)
{
client.Username = packet.Username;
if (!client.CheckUsername(packet.Username))
client.Kick("Inconsistent username");
if (packet.ProtocolVersion < ProtocolVersion)
client.Kick("Outdated client");
else
{
client.Host = packet.ServerHost + ":" + packet.ServerPort;
if (client.Server.EncryptionEnabled)
client.SendEncryptionRequest();
else if (IsAuthenticated(client))
Task.Factory.StartNew(client.SendLoginSequence);
}
}