Exemple #1
0
        public override async void Handle(HandleContext context)
        {
            var packet  = context.Packet;
            var session = context.Session;

            ServiceInvoke info = packet as ServiceInvoke;

            if (info != null)
            {
                context.Cancel = true;

                Console.WriteLine("收到调用{0}.{1} {2}->{3}",
                                  info.Name, info.Action, info.SrcUserId, info.DestUserId);

                var result = Invoke(info);

                await session.SendAsync(result);
            }
            else
            {
                Subscribe sub = packet as Subscribe;

                if (sub != null)
                {
                    context.Cancel = true;

                    Console.WriteLine("收到事件注册");

                    object service = GetService(sub.Name, sub.Instance);

                    var e = service.GetType().GetEvent(sub.Action);

                    //AddEventHandler(sub.Name, service);
                }
            }
        }
Exemple #2
0
 public async void Subscribe(Subscribe info)
 {
     await session.SendAsync(info);
 }