示例#1
0
 public static void SetCallback(
     IList <IHubConnectionAdapter> connections,
     StatisticsCollector statisticsCollector)
 {
     foreach (var connection in connections)
     {
         connection.On(SignalRConstants.RecordLatencyCallbackName, (IDictionary <string, object> data) =>
         {
             var receiveTimestamp = Util.Timestamp();
             data.TryGetTypedValue(SignalRConstants.Timestamp, out long sendTimestamp, Convert.ToInt64);
             var latency = receiveTimestamp - sendTimestamp;
             statisticsCollector.RecordLatency(latency);
             SignalRUtils.RecordRecvSize(data, statisticsCollector);
         });