Exemple #1
0
        /// <summary>
        /// 获取 TCP 服务器端同步调用队列
        /// </summary>
        /// <param name="sender">TCP 服务套接字数据发送</param>
        /// <param name="queueKey">关键字</param>
        /// <returns>TCP 服务器端同步调用队列</returns>
        public virtual ServerCallQueue Get(ServerSocketSenderBase sender, ref queueKeyType queueKey)
#endif
        {
            if (queueKey == null)
            {
                return(manager.Queues[0]);
            }
            return(manager.Queues[(uint)queueKey.GetHashCode() % manager.Queues.Length]);
        }
Exemple #2
0
 /// <summary>
 /// 检测当前时间戳
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="ticks"></param>
 /// <returns></returns>
 public bool Check(ServerSocketSenderBase sender, ref long ticks)
 {
     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);
     }
     return(true);
 }
 /// <summary>
 /// 自定义 TCP 服务器端同步调用任务
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="task"></param>
 internal CustomTaskAsyncServerCall(ServerSocketSenderBase sender, Action task)
 {
     this.sender = sender;
     this.task   = task;
 }
Exemple #4
0
 public static bool GetIsSocket(ServerSocketSenderBase socket)
 {
     return(socket.IsSocket);
 }
Exemple #5
0
 public static bool DeSerialize <valueType>(ServerSocketSenderBase socket, ref SubArray <byte> data, ref valueType value, bool isSimpleSerialize = false)
     where valueType : struct
 {
     return(socket.DeSerialize(ref data, ref value, isSimpleSerialize));
 }
Exemple #6
0
 public static void SetVerifyMethod(ServerSocketSenderBase socket)
 {
     socket.SetVerifyMethod();
 }
Exemple #7
0
 /// <summary>
 /// 获取 TCP 服务器端同步调用队列
 /// </summary>
 /// <typeparam name="queueKeyType">关键字类型</typeparam>
 /// <param name="sender">TCP 服务套接字数据发送</param>
 /// <param name="queueKey">关键字</param>
 /// <returns>TCP 服务器端同步调用队列</returns>
 public virtual ServerCallQueue Get <queueKeyType>(ServerSocketSenderBase sender, ref queueKeyType queueKey)