本文整理汇总了C#中NetState.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# NetState.Dispose方法的具体用法?C# NetState.Dispose怎么用?C# NetState.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetState
的用法示例。
在下文中一共展示了NetState.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunTaskNetStateConnect
void RunTaskNetStateConnect(NetState netState)
{
// 通知业务逻辑有客户端连接上来可以做一些初始化
// 或者判断是否允许本次连接
var tempEV = NetStateConnect;
if (tempEV != null)
{
var arg = new NetStateConnectEventArgs
{
NetState = netState,
AllowConnect = true
};
tempEV(this, arg);
if (arg.AllowConnect == false)
{
netState.Dispose();
return;
}
}
netState.Serial = netStateId++;
m_netStateManager.InternalAddNetState(netState.Serial, netState);
netState.Start();
}
示例2: OnReceive
public bool OnReceive(NetState ns)
{
ByteQueue buffer = ns.Buffer;
if (buffer == null || buffer.Length <= 0)
return true;
lock (buffer)
{
int length = buffer.Length;
while (length > 0)
{
int packetID = buffer.GetPacketID();
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)
break;
byte[] packetBuffer = BufferSize >= packetLength ? _buffers.AcquireBuffer() : 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)
_buffers.ReleaseBuffer(packetBuffer);
}
}
return true;
}
示例3: RunTaskNetStateDisconnect
private void RunTaskNetStateDisconnect(NetState netState)
{
m_netStateManager.InternalRemoveNetState(netState.Serial);
// 通知业务逻辑有客户端连接上来可以做一些初始化
// 或者判断是否允许本次连接
var tempEV = NetStateDisconnect;
if (tempEV != null)
{
var arg = new NetStateDisconnectEventArgs
{
NetState = netState,
};
tempEV(this, arg);
}
netState.ExitWorld();
netState.Dispose();
}
示例4: WorldServerExit
/// <summary>
///
/// </summary>
/// <param name="netState"></param>
/// <param name="packetReader"></param>
internal static void WorldServerExit( NetState netState, PacketReader packetReader )
{
netState.Send( new ExitAck( 3 ) );
netState.Dispose( true, 3 );
}