public byte[] SendMessage(ActorContext context, string msg) { var headers = new NameValueCollection { { "c", context.Request.C }, { "i", MessageType.Rep }, { "o", Convert.ToString(context.Request.O) }, { "code", Convert.ToString((int)StatusCode.Ok) }, { "format", "json" } }; //通知类型 return(ActorNetService.SendMessage(context, headers, Encoding.UTF8.GetBytes(msg))); }
private byte[] SendMessage <T>(ActorContext context, NameValueCollection header, T rep) { header["format"] = context.ResponseCovnert; var body = DistrictContainer.ServerIoc.ResolveKeyed <IResponseConvert>(context.ResponseCovnert) .SerializeObject(rep); if (Equals(context.ResponseCovnert, "protobuf")) { header["responsetype"] = typeof(T).Name; } if (Logger.IsDebugEnabled) { Logger.Debug($"S2C SEND #{context.Token.Rid}# #{context.RemoteIp}# {string.Join("&", header.AllKeys.Select(a => a + "=" + header[a]))} {(body==null?"":Encoding.UTF8.GetString(body))}"); } return(ActorNetService.SendMessage(context, header, body)); }