Exemple #1
0
        public void RegisterOuterEventSubscriber(string sessionId, string topic, SubscriberLocation location)
        {
            if (subscribers.ContainsKey(sessionId + topic))
            {
                return;
            }

            if (!events.ContainsKey(topic))
            {
                throw new ArgumentException("系统中没有topic为 [" + topic + "] 的事件");
            }
            EventCollector collector;

            if (eventCollectors.ContainsKey(sessionId))
            {
                collector = eventCollectors[sessionId];
            }
            else
            {
                collector = new EventCollector();
                eventCollectors.Add(sessionId, collector);
            }
            collector.RegisterEvent(topic, events[topic].EventInfo, kernel[events[topic].EventInfo.DeclaringType]);
            EventSubscriberInfo subInfo = new EventSubscriberInfo(topic, location, "", "");

            AddEventSubscriber(sessionId + topic, subInfo);
            if (!outerSubscriberMapping.ContainsKey(sessionId))
            {
                outerSubscriberMapping.Add(sessionId, new List <string>());
            }
            outerSubscriberMapping[sessionId].Add(topic);
            AddOuterSubscriberToPublisherInfo(sessionId + topic, subInfo);
            db.Store(new OuterEventInfo(sessionId, topic, location));
        }
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="topic">事件唯一名称</param>
 /// <param name="location">订阅者位置</param>
 /// <param name="componentName">组件名称</param>
 /// <param name="methodName">MethodInfo实例</param>
 public EventSubscriberInfo(string topic, SubscriberLocation location, string componentName, string methodName)
 {
     this.topic         = topic;
     this.location      = location;
     this.componentName = componentName;
     this.methodName    = methodName;
 }
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="topic">事件唯一名称</param>
 /// <param name="methodInfo">MethodInfo实例</param>
 /// <param name="serviceType">服务类型</param>
 /// <param name="location">订阅者位置</param>
 public EventSubscriberInfo(string topic, MethodInfo methodInfo, Type serviceType, SubscriberLocation location)
 {
     this.topic       = topic;
     this.serviceType = serviceType;
     this.methodInfo  = methodInfo;
     this.location    = location;
     methodName       = methodInfo.Name;
     componentName    = methodInfo.DeclaringType.Name;
 }
Exemple #4
0
 /// <summary>
 /// 注册外部的事件订阅者
 /// </summary>
 /// <param name="topic">事件唯一名称</param>
 /// <param name="location">订阅者位置</param>
 public void RegisterOuterEventSubscriber(string topic, SubscriberLocation location)
 {
     RegisterOuterEventSubscriber(SessionId, topic, location);
 }
Exemple #5
0
 public OuterEventInfo(string sessionId, string topic, SubscriberLocation location)
 {
     this.SessionId = sessionId;
     this.Topic     = topic;
     this.Location  = location;
 }
 /// <summary>
 /// 注册外部的事件订阅者
 /// </summary>
 /// <param name="topic">事件唯一名称</param>
 /// <param name="location">订阅者位置</param>
 public void RegisterOuterEventSubscriber(string topic, SubscriberLocation location)
 {
     RegisterOuterEventSubscriber(SessionId, topic, location);
 }
 public OuterEventInfo(string sessionId, string topic, SubscriberLocation location)
 {
     this.SessionId = sessionId;
     this.Topic = topic;
     this.Location = location;
 }
        public void RegisterOuterEventSubscriber(string sessionId, string topic, SubscriberLocation location)
        {
            if (subscribers.ContainsKey(sessionId + topic)) return;

            if (!events.ContainsKey(topic)) throw new ArgumentException("系统中没有topic为 [" + topic + "] 的事件");
            EventCollector collector;
            if (eventCollectors.ContainsKey(sessionId))
                collector = eventCollectors[sessionId];
            else {
                collector = new EventCollector();
                eventCollectors.Add(sessionId, collector);
            }
            collector.RegisterEvent(topic, events[topic].EventInfo, kernel[events[topic].EventInfo.DeclaringType]);
            EventSubscriberInfo subInfo = new EventSubscriberInfo(topic, location, "", "");
            AddEventSubscriber(sessionId + topic, subInfo);
            if (!outerSubscriberMapping.ContainsKey(sessionId)) outerSubscriberMapping.Add(sessionId, new List<string>());
            outerSubscriberMapping[sessionId].Add(topic);
            AddOuterSubscriberToPublisherInfo(sessionId + topic, subInfo);
            db.Store(new OuterEventInfo(sessionId, topic, location));
        }
 /// <summary>
 /// ���췽��
 /// </summary>
 /// <param name="topic">�¼�Ψһ����</param>
 /// <param name="location">�������</param>
 /// <param name="componentName">�������</param>
 /// <param name="methodName">MethodInfoʵ��</param>
 public EventSubscriberInfo(string topic, SubscriberLocation location, string componentName, string methodName)
 {
     this.topic = topic;
     this.location = location;
     this.componentName = componentName;
     this.methodName = methodName;
 }
 /// <summary>
 /// ���췽��
 /// </summary>
 /// <param name="topic">�¼�Ψһ����</param>
 /// <param name="methodInfo">MethodInfoʵ��</param>
 /// <param name="serviceType">��������</param>
 /// <param name="location">�������</param>
 public EventSubscriberInfo(string topic, MethodInfo methodInfo, Type serviceType, SubscriberLocation location)
 {
     this.topic = topic;
     this.serviceType = serviceType;
     this.methodInfo = methodInfo;
     this.location = location;
     methodName = methodInfo.Name;
     componentName = methodInfo.DeclaringType.Name;
 }