Beispiel #1
0
        public MainConnect
        (
            Socket main_server,
            ISQLDataBase sqldb,
            string user_info_path,
            string group_info_path,
            string applies_info_path,
            string chat_path,
            string cloud_path,
            string cloud_info_path,
            Action <LogLevel, string> notify,
            Action close
        )
        {
            IsClosed  = false;
            CloseLock = 0;

            Notify            = notify;
            SQLDB             = sqldb;
            UserInfoReader    = new KXTUserInfoReader(user_info_path, Notify);
            GroupInfoReader   = new KXTGroupInfoReader(group_info_path, Notify);
            UserAppliesReader = new KXTUserAppliesReader(applies_info_path, Notify);
            UserChatReader    = new KXTUserChatReader(chat_path, Notify);
            CloudReader       = new CloudInfoReader(cloud_info_path, Notify);
            CloudRootPath     = cloud_path;

            CloseServer = close;

            HeartTest = false;
            Timer     = new System.Timers.Timer
            {
                Interval  = HeartRequestInterval,
                AutoReset = false
            };
            Timer.Elapsed += HeartRequest_Trigger;
            Timer.Start();

            CacheTime = new System.Timers.Timer
            {
                Interval  = CacheVaildTime,
                AutoReset = false
            };
            CacheTime.Elapsed += CacheFresh_Trigger;
            Timer.Start();

            EmailRequestCache    = new ConcurrentDictionary <Guid, EmailRequestPackage>();
            OperationFinishCache = new ConcurrentDictionary <Guid, KeyValuePair <string, DateTime> >();

            MainServer = main_server;
            Buffer     = new byte[Datagram.DatagramLengthMax];
            MainServer.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, OnReceive, null);
        }
Beispiel #2
0
        public MainConnect
        (
            Socket main_server,
            string info_root_path,
            string file_root_path,
            Action <LogLevel, string> notify,
            Action close
        )
        {
            IsClosed = false;

            InfoReader = new CloudInfoReader(info_root_path, Notify);
            FileCache  = new ConcurrentDictionary <Guid, StreamBase>();

            FileRootPath = file_root_path;
            Notify       = notify;

            CloseServer = close;

            HeartTest = false;
            Timer     = new Timer
            {
                Interval  = HeartRequestInterval,
                AutoReset = false
            };
            Timer.Elapsed += HeartRequest_Trigger;
            Timer.Start();

            CacheTime = new Timer
            {
                Interval  = CacheVaildTime,
                AutoReset = false
            };
            CacheTime.Elapsed += CacheFresh_Trigger;
            CacheTime.Start();

            MainServer = main_server;
            Buffer     = new byte[Datagram.DatagramLengthMax];
            MainServer.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, OnReceive, null);
        }