예제 #1
0
        protected internal Task OnReceiveAsync(string msg, string key)
        {
            var ed = SubscribeService.GetEventDeclare(key);

            if (ed == null)
            {
                return(Task.FromResult <string>(null));
            }
            if (ed.IsArray && !ed.IsCopy)
            {
                var obj = msg.ToObject(ed.EventDataType.GenericTypeArguments[0]);
                var ed2 = SubscribeService.GetEventDeclare(ed.GetArrayName());
                ed2.setCache(obj);
                //转成集合
                if (ed2.CacheData.Count >= ed2.ListTake)
                {
                    ed2.rePublish();
                }
                return(Task.FromResult <string>(null));
            }
            else
            {
                var obj = msg.ToObject(ed.EventDataType);
                return((Task)ed.MethodInvoke.Invoke(ed.CreateServiceInstance(), new object[] { obj }));
            }
        }