Пример #1
0
 public void Dispose()
 {
     heartTimer.Dispose();
     CurrentSender.Dispose();
     currentPool.Dispose();
     currSocket.Dispose();
     OfflineContainer.Dispose();
     _model = null;
     Console.WriteLine("资源清理完成");
 }
Пример #2
0
 public static SocketPoolManager Init(int heartFreq = 60000, int retryNumber = 3, int retryInterval = 30000)
 {
     if (_model == null)
     {
         lock (_lock)
         {
             if (_model == null)
             {
                 _model = new SocketPoolManager(heartFreq);
                 _model.CurrentSender.RetryNumber   = retryNumber;
                 _model.CurrentSender.RetryInterval = retryInterval;
             }
         }
     }
     return(_model);
 }
Пример #3
0
        /// <summary>
        /// 创建socket广播
        /// </summary>
        /// <param name="socketServer"></param>
        /// <param name="adminFiler"></param>
        /// <returns></returns>
        public static SocketSpreader SocketAdminManager(SocketPool.SocketPoolManager socketServer, Filter.ISocketFilter adminFiler)
        {
            //格式 message;user1;user2;user3
            Action <string> action = (msg) =>
            {
                var arr = msg.Split(';');
                if (arr.Length > 1)
                {
                    for (int i = 1; i < arr.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(arr[i]))
                        {
                            socketServer.Notify(arr[0], arr[i]);
                        }
                    }
                }
                else
                {
                    socketServer.Notify(msg);
                }
            };

            return(new SocketSpreader(action, adminFiler));
        }