private bool TryGetSession(object sender, out HubClientSession session) { var btn = sender as Button; session = btn?.CommandParameter as HubClientSession; return(session != null); }
internal void Load(HubClientSession session) { _sess = session; UnsavedText = _sess.JsonConfig ?? ""; UpdateStates(); UpdateTitle($" {_sess}"); }
internal static void Show(HubClientSession session) { var win = new CfgEditorWindow1(); var vm = Components.Scope.Resolve <ConfigEditorVM>(); win.DataContext = vm; vm.Load(session); win.Show(); }
private bool IsValidSession(HubCallerContext context, out HubClientSession session) { if (!context.TryGetSession(out session)) { return(false); } session.HubName = TargetHubName; session.HubClientIP = context.Request.Environment["server.RemoteIpAddress"].ToString(); return(true); }
public static bool TryGetSession(this HubCallerContext context, out HubClientSession session) { if (!context.Request.TryGetSession(out session)) { return(false); } session.ConnectionId = context.ConnectionId; session.LastActivity = DateTime.Now; return(true); }
private static void ConsolidateLogs(HubClientSession session, HubClientSession existing) { if (existing.Logs.Any() && !session.Logs.Any()) { session.Logs.Add(existing.Logs); } if (existing.Errors.Any() && !session.Errors.Any()) { session.Errors.Add(existing.Errors); } }
private static string ComposeSessionJson(IHubClientSettings cfg) { var sess = new HubClientSession { UserAgent = cfg.UserAgent, AgentVersion = CurrentExe.GetVersion(), ComputerName = Environment.MachineName, //JsonConfig = JsonConvert.SerializeObject(cfg), JsonConfig = cfg.ReadSavedFile(), }; return(JsonConvert.SerializeObject(sess)); }
private void Add(string userAgent) { var sess = new HubClientSession { HubName = "MessageBroadcastHub1", UserAgent = userAgent, AgentVersion = "1.0.17252.0043", ConnectionId = userAgent.SHA1ForUTF8().Substring(9), LastActivity = DateTime.Now, HubClientIP = "123.456.789.1011", ComputerName = "FATS-SVR2", CurrentState = new CurrentClientState { PublicIP = "221.123.456.789" } }; sess.Logs.Add(new LogEntry("sample msg 1")); sess.Logs.Add(new LogEntry("sample msg 2")); List.Add(sess); }
public static bool TryGetSession(this IRequest request, out HubClientSession session) { if (request.Environment.TryGetValue(ENV_KEY, out object sessionObj)) { session = sessionObj as HubClientSession; return(session != null); } var timestamp = request.Headers[TIME_HEADER]; var authHeadr = request.Headers[AUTH_HEADER]; if (TryDecrypt(authHeadr, timestamp, out string json)) { session = JsonConvert.DeserializeObject <HubClientSession>(json); request.Environment.Add(ENV_KEY, session); return(true); } else { session = null; return(false); } }
public void AddOrUpdate(HubClientSession session) { var connId = session.ConnectionId; var existing = List.FirstOrDefault(_ => _.ConnectionId == connId); if (existing == null) { ClientStateListeners.Notify.ClientConnected(session); } else { try { AsUI(_ => ConsolidateLogs(session, existing)); Remove(connId); } catch (Exception ex) { Alert.Show(ex, "AddOrUpdate existing client"); } ClientStateListeners.Notify.ClientInteracted(session); } AsUI(_ => List.Add(session)); }
private void ShowScreenshotIfAny(HubClientSession session) { var cap = $"[{DateTime.Now.ToShortTimeString()}] {session.UserAgent}"; AsUI(_ => BitmapWindow1.Show(cap, session.CurrentState?.ScreenshotB64)); }