本文整理匯總了C#中Server.Network.NetState.GetHandler方法的典型用法代碼示例。如果您正苦於以下問題:C# NetState.GetHandler方法的具體用法?C# NetState.GetHandler怎麽用?C# NetState.GetHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Server.Network.NetState
的用法示例。
在下文中一共展示了NetState.GetHandler方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: HandleReceive
public bool HandleReceive( NetState ns )
{
ByteQueue buffer = ns.Buffer;
if ( buffer == null || buffer.Length <= 0 )
return true;
lock ( buffer )
{
int length = buffer.Length;
if ( !ns.Seeded )
{
if (buffer.GetPacketID() == 0xEF)
{
// new packet in client 6.0.5.0 replaces the traditional seed method with a seed packet
// 0xEF = 239 = multicast IP, so this should never appear in a normal seed. So this is backwards compatible with older clients.
ns.Seeded = true;
}
else if (buffer.Length >= 4)
{
buffer.Dequeue( m_Peek, 0, 4 );
int seed = (m_Peek[0] << 24) | (m_Peek[1] << 16) | (m_Peek[2] << 8) | m_Peek[3];
if ( seed == 0 )
{
Console.WriteLine( "Login: {0}: Invalid client detected, disconnecting", ns );
ns.Dispose();
return false;
}
ns.m_Seed = seed;
ns.Seeded = true;
length = buffer.Length;
}
else
{
return true;
}
}
while ( length > 0 && ns.Running )
{
int packetID = buffer.GetPacketID();
if (!ns.SentFirstPacket && packetID != 0xF0 && packetID != 0xF1 && packetID != 0xCF && packetID != 0x80 && packetID != 0x91 && packetID != 0xA4 && packetID != 0xEF)
{
Console.WriteLine( "Client: {0}: Encrypted client detected, disconnecting", ns );
ns.Dispose();
break;
}
PacketHandler handler = ns.GetHandler( packetID );
if ( handler == null )
{
byte[] data = new byte[length];
length = buffer.Dequeue( data, 0, length );
new PacketReader( data, length, false ).Trace( ns );
break;
}
int packetLength = handler.Length;
if ( packetLength <= 0 )
{
if ( length >= 3 )
{
packetLength = buffer.GetPacketLength();
if ( packetLength < 3 )
{
ns.Dispose();
break;
}
}
else
{
break;
}
}
if ( length >= packetLength )
{
if ( handler.Ingame && ns.Mobile == null )
{
Console.WriteLine( "Client: {0}: Sent ingame packet (0x{1:X2}) before having been attached to a mobile", ns, packetID );
ns.Dispose();
break;
}
else if ( handler.Ingame && ns.Mobile.Deleted )
{
ns.Dispose();
break;
}
else
//.........這裏部分代碼省略.........
示例2: HandleReceive
private bool HandleReceive( NetState ns )
{
lock ( ns )
{
ByteQueue buffer = ns.Buffer;
if ( buffer == null )
return true;
int length = buffer.Length;
if ( !ns.Seeded )
{
if ( length >= 4 )
{
buffer.Dequeue( m_Peek, 0, 4 );
int seed = (m_Peek[0] << 24) | (m_Peek[1] << 16) | (m_Peek[2] << 8) | m_Peek[3];
if (log.IsDebugEnabled)
log.DebugFormat("Login: {0}: Seed is 0x{1:X8}", ns, seed);
if ( seed == 0 )
{
log.WarnFormat("Login: {0}: Invalid client detected, disconnecting", ns);
ns.Dispose();
return false;
}
ns.m_Seed = seed;
ns.Seeded = true;
}
return true;
}
while ( length > 0 && ns.Running )
{
int packetID = buffer.GetPacketID();
if ( !ns.SentFirstPacket && packetID != 0xF0 && packetID != 0xF1 && packetID != 0xCF && packetID != 0x80 && packetID != 0x91 && packetID != 0xA4 && packetID != 0xBF )
{
log.WarnFormat("Client: {0}: Encrypted client detected, disconnecting", ns);
ns.Dispose();
break;
}
PacketHandler handler = ns.GetHandler( packetID );
if ( handler == null )
{
byte[] data = new byte[length];
length = buffer.Dequeue( data, 0, length );
new PacketReader( data, length, false ).Trace( ns );
break;
}
int packetLength = handler.Length;
if ( packetLength <= 0 )
{
if ( length >= 3 )
{
packetLength = buffer.GetPacketLength();
if ( packetLength < 3 )
{
ns.Dispose();
break;
}
}
else
{
break;
}
}
if ( length >= packetLength )
{
if ( handler.Ingame && ns.Mobile == null )
{
log.WarnFormat("Client: {0}: Sent ingame packet (0x{1:X2}) before having been attached to a mobile",
ns, packetID);
ns.Dispose();
break;
}
else if ( handler.Ingame && ns.Mobile.Deleted )
{
ns.Dispose();
break;
}
else
{
ThrottlePacketCallback throttler = handler.ThrottleCallback;
if ( throttler != null && !throttler( ns ) )
{
m_Throttled.Enqueue( ns );
//.........這裏部分代碼省略.........
示例3: HandleReceive
public void HandleReceive(NetState ns)
{
ByteQueue buffer = ns.Buffer;
if (buffer == null || buffer.Length <= 0)
{
return;
}
lock (buffer)
{
if (!ns.Seeded)
{
if (!HandleSeed(ns, buffer))
{
return;
}
}
int length = buffer.Length;
while (length > 0 && ns.Running)
{
int packetID = buffer.GetPacketID();
if (CheckEncrypted(ns, packetID))
{
break;
}
PacketHandler handler = ns.GetHandler(packetID);
if (handler == null)
{
var data = new byte[length];
length = buffer.Dequeue(data, 0, length);
new PacketReader(data, length, false).Trace(ns);
break;
}
int packetLength = handler.Length;
if (packetLength <= 0)
{
if (length >= 3)
{
packetLength = buffer.GetPacketLength();
if (packetLength < 3)
{
ns.Dispose();
break;
}
}
else
{
break;
}
}
if (length >= packetLength)
{
if (handler.Ingame)
{
if (ns.Mobile == null)
{
Utility.PushColor(ConsoleColor.DarkRed);
Console.WriteLine(
"Client: {0}: Sent ingame packet (0x{1:X2}) before having been attached to a mobile", ns, packetID);
Utility.PopColor();
ns.Dispose();
break;
}
else if (ns.Mobile.Deleted)
{
ns.Dispose();
break;
}
}
ThrottlePacketCallback throttler = handler.ThrottleCallback;
if (throttler != null && !throttler(ns))
{
m_Throttled.Enqueue(ns);
return;
}
PacketReceiveProfile prof = null;
if (Core.Profiling)
{
prof = PacketReceiveProfile.Acquire(packetID);
}
if (prof != null)
{
prof.Start();
}
//.........這裏部分代碼省略.........
示例4: HandleReceive
public void HandleReceive( NetState ns )
{
ByteQueue buffer = ns.Buffer;
if ( buffer == null || buffer.Length <= 0 )
return;
lock ( buffer )
{
if ( !ns.Seeded ) {
if (!HandleSeed(ns, buffer))
return;
}
int length = buffer.Length;
while ( length > 0 && ns.Running ) {
int packetID = buffer.GetPacketID();
if (CheckEncrypted(ns, packetID))
break;
PacketHandler handler = ns.GetHandler( packetID );
if ( handler == null ) {
byte[] data = new byte[length];
length = buffer.Dequeue( data, 0, length );
new PacketReader( data, length, false ).Trace( ns );
break;
}
int packetLength = handler.Length;
if ( packetLength <= 0 ) {
if ( length >= 3 ) {
packetLength = buffer.GetPacketLength();
if ( packetLength < 3 ) {
ns.Dispose();
break;
}
} else {
break;
}
}
if ( length >= packetLength ) {
if (handler.Ingame) {
if (ns.Mobile == null ) {
Console.WriteLine( "Client: {0}: Sent ingame packet (0x{1:X2}) before having been attached to a mobile", ns, packetID );
ns.Dispose();
break;
} else if (ns.Mobile.Deleted) {
ns.Dispose();
break;
}
}
ThrottlePacketCallback throttler = handler.ThrottleCallback;
if ( throttler != null && !throttler( ns ) ) {
m_Throttled.Enqueue( ns );
return;
}
PacketReceiveProfile prof = null;
if (Core.Profiling) prof = PacketReceiveProfile.Acquire( packetID );
if ( prof != null ) {
prof.Start();
}
byte[] packetBuffer;
if ( BufferSize >= packetLength )
packetBuffer = m_Buffers.AcquireBuffer();
else
packetBuffer = new byte[packetLength];
packetLength = buffer.Dequeue( packetBuffer, 0, packetLength );
PacketReader r = new PacketReader( packetBuffer, packetLength, handler.Length != 0 );
handler.OnReceive( ns, r );
length = buffer.Length;
if ( BufferSize >= packetLength )
m_Buffers.ReleaseBuffer( packetBuffer );
if ( prof != null ) {
prof.Finish( packetLength );
}
} else {
break;
}
}
}
}
示例5: HandleReceive
public bool HandleReceive(NetState ns)
{
ByteQueue buffer = ns.Buffer;
if (buffer == null || buffer.Length <= 0)
return true;
lock (buffer)
{
int length = buffer.Length;
if (!ns.Seeded)
{
//if (ns.Version > ns.ExpansionInfo.RequiredClient)
//{
// ns.IsKRClient = true;
//}
/*
* Genova: Packet Logger
Console.WriteLine("packet vindo de buffer: {0}", buffer.GetPacketID());
Console.WriteLine("Tamanho do buffer: {0}", length);
*/
// Genova: suporte ao UO:KR.
if (buffer.GetPacketID() == 0xFF)
{
// Packet 255 = 0xFF = Client KR.
ns.IsKRClient = true;
}
if (buffer.GetPacketID() == 0xEF)
{
// new packet in client 6.0.5.0 replaces the traditional seed method with a seed packet
// 0xEF = 239 = multicast IP, so this should never appear in a normal seed. So this is backwards compatible with older clients.
ns.Seeded = true;
}
else if (buffer.Length >= 4)
{
// Genova: suporte ao UO:KR.
// Se for KR, isso vai continuar como -1 temporariamente
int seed = -1;
if (!ns.IsKRClient)
{
buffer.Dequeue(m_Peek, 0, 4);
seed = (m_Peek[0] << 24) | (m_Peek[1] << 16) | (m_Peek[2] << 8) | m_Peek[3];
if (seed == 0)
{
Console.WriteLine("Login: {0}: Invalid client detected, disconnecting", ns);
ns.Dispose();
return false;
}
}
ns.m_Seed = seed;
ns.Seeded = true;
length = buffer.Length;
}
else
{
return true;
}
}
while (length > 0 && ns.Running)
{
int packetID = buffer.GetPacketID();
if (!ns.SentFirstPacket && packetID != 0xF0 && packetID != 0xF1 && packetID != 0xCF && packetID != 0x80 && packetID != 0x91 && packetID != 0xA4 && packetID != 0xEF)
{
Console.WriteLine("Client: {0}: Encrypted client detected, disconnecting", ns);
ns.Dispose();
break;
}
PacketHandler handler = ns.GetHandler(packetID);
if (handler == null)
{
byte[] data = new byte[length];
length = buffer.Dequeue(data, 0, length);
new PacketReader(data, length, false).Trace(ns);
break;
}
int packetLength = handler.Length;
if (packetLength <= 0)
{
if (length >= 3)
{
packetLength = buffer.GetPacketLength();
if (packetLength < 3)
{
//.........這裏部分代碼省略.........