Exemplo n.º 1
0
        public void PushMessage <T>(PirateSession session, T t)
        {
            var headers = new NameValueCollection
            {
                { "c", typeof(T).Name },
                { "i", MessageType.Boradcast },
                { "format", DefaultResponseCovnert } // TODO 默认解析器
            };

            if (Equals(DefaultResponseCovnert, "protobuf"))
            {
                headers["responsetype"] = typeof(T).Name;
            }


            if (Logger.IsDebugEnabled && t != null)
            {
                Logger.Debug($"S2C PUSH #{session.Id}# {string.Join("&", headers.AllKeys.Select(a => a + "=" + headers[a]))} {JsonConvert.SerializeObject(t)}");
            }

            ActorNetService.PushMessage(session.FrontendID, headers, DistrictContainer.ServerIoc.ResolveKeyed <IResponseConvert>(DefaultResponseCovnert).SerializeObject(t));
        }