コード例 #1
0
        public void StartSession(SignalrRequest signalrRequest)
        {
            /// starts session for a particular browser client
            var jsonData = signalrRequest.OwinContext.Response.ReadBody();

            if (string.IsNullOrEmpty(jsonData))
            {
                return;
            }

            var negotiateResponseObj = JsonConvert.DeserializeObject <NegotiateResponse>(jsonData);

            var sessionEntity = new SessionDto
            {
                ConnectionId    = negotiateResponseObj.ConnectionId,
                ConnectionToken = negotiateResponseObj.ConnectionToken,
                NegotiateData   = jsonData,
                StartTimeStamp  = DateTime.UtcNow.Ticks,
                FinishTimeStamp = 0
            };

            var saved = sessionEntity.Save(_sqlOperation);

            if (saved)
            {
                AddRequestTrace(signalrRequest, negotiateResponseObj.ConnectionToken);
                AddHubData(sessionEntity.ConnectionId, signalrRequest.QueryCollection.ConnectionData);
            }
        }
コード例 #2
0
        private bool AddRequestTrace(SignalrRequest signalrRequest, string connectionToken)
        {
            var sessionObj = _sqlOperation.Select <SessionDto>(SelectSqlQuery.GetSingle_Session_By_ConnectionToken,
                                                               connectionToken);

            if (sessionObj == null)
            {
                return(false);
            }


            var owinRequest = signalrRequest.OwinContext.Request;

            var requestEntity = new RequestDto
            {
                SessionId          = sessionObj.SessionId,
                OwinRequestId      = signalrRequest.OwinRequestId,
                RequestUrl         = owinRequest.Uri.AbsoluteUri,
                RemoteIp           = owinRequest.RemoteIpAddress,
                RemotePort         = owinRequest.RemotePort ?? 0,
                ServerIp           = owinRequest.LocalIpAddress,
                ServerPort         = owinRequest.LocalPort ?? 0,
                RequestContentType = owinRequest.ContentType,
                RequestBody        = owinRequest.ReadBody(),
                Protocol           = owinRequest.Protocol,
                QueryString        = owinRequest.QueryString.Value,
                User               = owinRequest.User?.Identity?.Name,
                RequestTimeStamp   = DateTime.UtcNow.Ticks,
                IsWebSocketRequest = signalrRequest.QueryCollection.Transport == "webSockets",
                RequestType        = signalrRequest.Type.ToString()
            };

            return(requestEntity.Save(_sqlOperation));
        }
コード例 #3
0
 protected SignalrInterceptorBase(IOwinContext owinContext, TimeSpan pipelineProcessingTime)
 {
     CurrentRequest         = new SignalrRequest(owinContext);
     PipelineProcessingTime = pipelineProcessingTime;
     PipelineProcessed      = pipelineProcessingTime != TimeSpan.Zero;
 }
コード例 #4
0
 public void CompleteRequestTrace(SignalrRequest signalrRequest)
 {
     _sqlOperation.ExecuteAsync(ExecuteSqlQuery.Update_RequestOnCompleted, DateTime.UtcNow.Ticks, 0,
                                signalrRequest.OwinContext.Response.StatusCode, signalrRequest.OwinContext.Response.ReadBody(), signalrRequest.OwinRequestId);
 }
コード例 #5
0
 public bool AddRequestTrace(SignalrRequest signalrRequest)
 {
     return(AddRequestTrace(signalrRequest, signalrRequest.QueryCollection.ConnectionToken));
 }