IMongoDatabase GetConnection()
 {
     if (database == null)
     {
         var connectionString = MQMConfigurationSection.GetConfig().StorageConnectionString;
         if (client == null)
         {
             client = new MongoClient(connectionString);
         }
         database = client.GetDatabase(new MongoUrl(connectionString).DatabaseName);
     }
     return(database);
 }
예제 #2
0
        private void RetryRemotePushFailure()
        {
            var records = Storage.GetRemotePushFailureRecords(AgentId);

            foreach (var item in records)
            {
                try
                {
                    Adapter.Publish(item.Content.Descriptions, item.Content.Content);
                    Storage.RemoveRemotePushFailureRecord(item._id);
                }
                catch { }
            }
            Task.Factory.StartNew(() =>
            {
                Thread.Sleep(MQMConfigurationSection.GetConfig().RetryRemotePushFailureInterval);
                RetryRemotePushFailure();
            });
        }
예제 #3
0
        /// <summary>
        /// 身份验证
        /// </summary>
        /// <param name="subscriber">订阅对象信息</param>
        /// <param name="key">密钥</param>
        /// <returns>是否成功</returns>
        public bool Authentication(ClientIndetity subscriber, string key)
        {
            if (key.Trim() != MQMConfigurationSection.GetConfig().Password.Trim())
            {
                throw new NotAuthenticationException("授权验证失败,请提供正确的授权码!");
            }
            ClientIndetity old;

            if (Storage.TryGetClientIndetity(subscriber.PublisherId, out old))
            {
                old.SessionId   = subscriber.SessionId;
                old.IsWebSite   = subscriber.IsWebSite;
                old.WebSiteHost = subscriber.WebSiteHost;
                old.AgentId     = AgentId;
                Storage.SaveUpdateClientIndetity(old);
            }
            else
            {
                subscriber.AgentId = AgentId;
                Storage.AddClientIndetity(subscriber);
            }
            return(true);
        }
예제 #4
0
 public static MQMServer InitServer()
 {
     return(InitServer(MQMConfigurationSection.GetConfig().Port));
 }
예제 #5
0
        /// <summary>
        /// 获取配置实例
        /// </summary>
        /// <returns></returns>
        public static MQMConfigurationSection GetConfig()
        {
            MQMConfigurationSection section = (MQMConfigurationSection)ConfigurationManager.GetSection("MessageServer");

            return(section);
        }