Beispiel #1
0
 public void PostMessage(IMessagePoster poster, string text)
 {
     Message m = new Message(poster,text,messageLifeTime);
     lock(this.queue) {
         this.queue.Enqueue(m);
     }
 }
Beispiel #2
0
        public void PostMessage(IMessagePoster poster, string text)
        {
            Message m = new Message(poster, text, messageLifeTime);

            lock (this.queue) {
                this.queue.Enqueue(m);
            }
        }
Beispiel #3
0
        void IZeroOption.Load(bool _)
        {
            #region 配置载入

            var option = ConfigurationHelper.Get <Dictionary <string, string> >(sectionName);
            if (option == null)
            {
                return;
            }
            foreach (var kv in option)
            {
                if (kv.Value.IsBlank())
                {
                    continue;
                }

                if ("LocalTunnel".IsMe(kv.Key))
                {
                    LocalTunnel = bool.TryParse(kv.Value, out var bl) && bl;
                }
                else if ("Default".IsMe(kv.Key))
                {
                    DefaultPosterName = kv.Value;
                }
                else
                {
                    PosterServices.Add(kv.Key, kv.Value.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList());
                }
            }
            #endregion
            #region 构造发送器

            posters = new Dictionary <string, IMessagePoster>();
            foreach (var poster in DependencyHelper.RootProvider.GetServices <IMessagePoster>())
            {
                posters.TryAdd(poster.GetTypeName(), poster);
            }

            foreach (var poster in posters)
            {
                if (PosterServices.TryGetValue(poster.Key, out var services) && services != null && services.Count != 0)
                {
                    BindingPoster(poster.Key, poster.Value, services);
                }
            }

            if (DefaultPosterName.IsBlank() || !posters.TryGetValue(DefaultPosterName, out DefaultPoster))
            {
                var f = posters.FirstOrDefault();
                if (!f.Key.IsBlank())
                {
                    DefaultPosterName = f.Key;
                    DefaultPoster     = f.Value;
                }
            }

            #endregion
        }
Beispiel #4
0
 public Message(IMessagePoster poster, string text, DateTime posted, uint milliseconds)
 {
     this.poster       = poster;
     this.text         = text;
     this.posted       = posted;
     this.released     = new DateTime(this.posted.Ticks).AddMilliseconds(milliseconds);
     this.totalMessage = string.Empty;
     this.totalMessage = generateTotalMessage();
 }
Beispiel #5
0
 public void SetUp()
 {
     if (poster != null)
     {
         return;
     }
     poster = new HttpPoster();
     HttpApp.AddMessageMvcHttpClient(DependencyHelper.ServiceCollection);
     DependencyHelper.Flush();
 }
Beispiel #6
0
 /// <summary>
 ///     手动注销
 /// </summary>
 void BindingPoster(string posterName, IMessagePoster poster, IEnumerable <string> services)
 {
     foreach (var service in services)
     {
         if (!ServiceMap.TryGetValue(service, out var items))
         {
             ServiceMap.Add(service, items = new Dictionary <string, IMessagePoster>());
         }
         items[posterName] = poster;
     }
 }
Beispiel #7
0
        public Channel(string id, string name, IMessagePoster messagePoster)
        {
            if (id == null) throw new ArgumentNullException(nameof(id));
            if (name == null) throw new ArgumentNullException(nameof(name));
            if (messagePoster == null) throw new ArgumentNullException(nameof(messagePoster));

            _messagePoster = messagePoster;

            Id = id;
            Name = name;
        }
Beispiel #8
0
        public Room(string name, IMessagePoster messagePoster)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (messagePoster == null)
            {
                throw new ArgumentNullException(nameof(messagePoster));
            }

            _messagePoster = messagePoster;
            Name           = name;
        }
Beispiel #9
0
        /// <summary>
        ///     手动注册
        /// </summary>
        internal void RegistPoster(IMessagePoster poster, params string[] services)
        {
            var name = poster.GetTypeName();

            posters[name] = poster;
            if (!PosterServices.ContainsKey(name))
            {
                PosterServices.Add(name, services.ToList());
            }
            else
            {
                PosterServices[name].AddRange(services);
            }
            BindingPoster(name, poster, services);
        }
Beispiel #10
0
        public Channel(string id, string name, IMessagePoster messagePoster)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (messagePoster == null)
            {
                throw new ArgumentNullException(nameof(messagePoster));
            }

            _messagePoster = messagePoster;

            Id   = id;
            Name = name;
        }
Beispiel #11
0
        static IInlineMessage CheckMessage(IMessagePoster poster, IMessageItem message)
        {
            var re = poster.CheckMessage(message);

            if (re != null)
            {
                return(re);
            }

            var ctx = GlobalContext.CurrentNoLazy;

            if (message is IInlineMessage inline)
            {
                if (ctx != null && ctx.Message == message)
                {
                    inline = inline.CopyToRequest();
                }
                else
                {
                    inline.ResetToRequest();
                }
            }
            else
            {
                inline = new InlineMessage
                {
                    ID        = message.ID,
                    Service   = message.Service,
                    Method    = message.Method,
                    Result    = message.Result,
                    Argument  = message.Argument,
                    DataState = MessageDataState.ArgumentOffline
                };
            }
            inline.CheckPostTraceInfo();

            return(inline);
        }
Beispiel #12
0
 /// <summary>
 ///     手动注册
 /// </summary>
 public static void RegistPoster(IMessagePoster poster, params string[] services)
 {
     MessagePostOption.Instance.RegistPoster(poster, services);
 }
Beispiel #13
0
 public Message(IMessagePoster poster, string text, uint milliseconds) : this(poster, text, DateTime.Now, milliseconds)
 {
 }
Beispiel #14
0
 public Message(IMessagePoster poster, string text, uint milliseconds)
     : this(poster,text,DateTime.Now,milliseconds)
 {
 }
Beispiel #15
0
 public Message(IMessagePoster poster, string text, DateTime posted, uint milliseconds)
 {
     this.poster = poster;
     this.text = text;
     this.posted = posted;
     this.released = new DateTime(this.posted.Ticks).AddMilliseconds(milliseconds);
     this.totalMessage = string.Empty;
     this.totalMessage = generateTotalMessage();
 }