public void Set(TcpInternalStreamServer.ServerSocketSender sender) { this.Sender = sender; switch (sender.ServerTaskType) { case TcpStreamServer.ServerTaskType.TcpQueue: TcpServer.ServerCallQueue.Default.Add(this); return; case TcpStreamServer.ServerTaskType.Queue: sender.Server.CallQueue.Add(this); return; } }
protected static bool verify(TcpInternalStreamServer.ServerSocketSender sender, ulong randomPrefix, byte[] md5Data, ref long ticks) { TcpServer.ServerBase <TcpInternalStreamServer.ServerAttribute> server = sender.Server; TcpServer.ServerBaseAttribute attribute = server.Attribute; if (TcpServer.TimeVerifyServer.CheckVerifyString(server, attribute)) { return(true); } if (md5Data != null && md5Data.Length == 16) { if (ticks <= lastVerifyTicks && ticks != sender.TimeVerifyTicks) { if (sender.TimeVerifyTicks == 0) { while (System.Threading.Interlocked.CompareExchange(ref lastVerifyTickLock, 1, 0) != 0) { AutoCSer.Threading.ThreadYield.Yield(AutoCSer.Threading.ThreadYield.Type.TimeVerifyServerSetTicks); } sender.TimeVerifyTicks = ++lastVerifyTicks; System.Threading.Interlocked.Exchange(ref lastVerifyTickLock, 0); } ticks = sender.TimeVerifyTicks; return(false); } if (TcpServer.TimeVerifyServer.IsMd5(TcpServer.TimeVerifyServer.Md5(attribute.VerifyString, randomPrefix, ticks), md5Data) == 0) { if (ticks > lastVerifyTicks) { while (System.Threading.Interlocked.CompareExchange(ref lastVerifyTickLock, 1, 0) != 0) { AutoCSer.Threading.ThreadYield.Yield(AutoCSer.Threading.ThreadYield.Type.TimeVerifyServerSetTicks); } if (ticks > lastVerifyTicks) { lastVerifyTicks = ticks; } System.Threading.Interlocked.Exchange(ref lastVerifyTickLock, 0); } if (!attribute.IsMarkData || sender.SetMarkData(attribute.VerifyHashCode ^ randomPrefix)) { return(true); } } } ticks = 0; return(false); }