Exemplo n.º 1
0
 protected TResp HandleServiceCall <TReq, TResp>(TReq req, TResp resp, Action <TReq, TResp> handler, SessionAuthOptions authOptions = null)
     where TReq : BaseReq
     where TResp : BaseResp, new()
 {
     try
     {
         string clientAddress = ServiceUtils.GetClientAddress();
         Server.AccessManager.CheckAccess(clientAddress);
     }
     catch (AuthException)
     {
         throw new WebFaultException(System.Net.HttpStatusCode.Forbidden);
     }
     try
     {
         if (authOptions == null)
         {
             authOptions = new SessionAuthOptions();
         }
         var sessionAuth    = GetSessionAuth(req);
         var sessionManager = Server.SessionManager;
         sessionManager.Authenticate(sessionAuth, authOptions);
         handler(req, resp);
         return(resp);
     }
     catch (Exception e)
     {
         //log.Error("HandleServiceCall top-level exception handler", e);
         return(new TResp().WithException(e));
     }
 }
Exemplo n.º 2
0
 protected TResp HandleServiceCall <TReq, TResp>(TReq req, TResp resp, Action <TReq, TResp> handler, SessionAuthOptions authOptions = null)
     where TReq : BaseReq
     where TResp : BaseResp, new()
 {
     try
     {
         if (authOptions == null)
         {
             authOptions = new SessionAuthOptions();
         }
         var sessionAuth    = GetSessionAuth(req);
         var sessionManager = Server.SessionManager;
         sessionManager.Authenticate(sessionAuth, authOptions);
         handler(req, resp);
         return(resp);
     }
     catch (Exception e)
     {
         //log.Error("HandleServiceCall top-level exception handler", e);
         return(new TResp().WithException(e));
     }
 }