public static Inline ToInline(this SessionNode node, Channel chan = null) { return(new Hyperlink { Inlines = { new InlineUIContainer(new Image { Source = new CroppedBitmap(App.Current.CombinedImageResource, node.IsOfficial ? new Int32Rect(96, 0, 24, 24) : new Int32Rect(0, 24, 24, 24)), Width = 16, Height = 16, Margin = new Thickness(4) }), new Run(node.SessionName) { FontWeight = FontWeights.Bold } }, Foreground = Brushes.White, TextDecorations = null, NavigateUri = new Uri($"flist://session/{node.SessionADH}"), ToolTip = node.SessionName }); }
static void Main(string[] args) { Sodao.FastSocket.SocketBase.Log.Trace.EnableConsole(); Sodao.FastSocket.SocketBase.Log.Trace.EnableDiagnostic(); var client = Sodao.Zookeeper.ZookClientPool.Get("zk1"); client.Register(new WatcherWrapper(e => { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.Path); Console.WriteLine(e.Type.ToString()); Console.WriteLine(e.State.ToString()); Console.ForegroundColor = ConsoleColor.Gray; })); var watcher = new ChildrenWatcher(client, "/", c => { Console.WriteLine(string.Join("-", c)); }); Console.ReadLine(); var sessionNode = new SessionNode(client, "/tempABC", null, IDs.OPEN_ACL_UNSAFE); Console.ReadLine(); sessionNode.Close(); Console.ReadLine(); }
internal SessionNode OpenTarget(ProfilingTarget target, string filename) { for (int i = 0; i < _sessions.Count; i++) { if (_sessions[i].Filename == filename) { throw new InvalidOperationException(Strings.PerformanceSessionAlreadyOpen.FormatUI(filename)); } } uint prevSibl; if (_sessions.Count > 0) { prevSibl = _sessions[_sessions.Count - 1].ItemId; } else { prevSibl = VSConstants.VSITEMID_NIL; } var node = new SessionNode(_serviceProvider, this, target, filename); _sessions.Add(node); OnItemAdded(VSConstants.VSITEMID_ROOT, prevSibl, node.ItemId); if (_activeSession == VSConstants.VSITEMID_NIL) { SetActiveSession(node); } return(node); }
public void PingResult(PingResultEvent e, SessionNode session) { float pingClientRealTime = session.clientTime.PingClientRealTime; long num3 = e.ServerTime - ((long)(((pingClientRealTime + UnityTime.realtimeSinceStartup) * 1000f) / 2f)); base.Log.InfoFormat("PingResult newDiffToServer={0} e={1}", num3, e); TimeService.DiffToServer = num3; }
internal void SetActiveSession(SessionNode node) { uint oldItem = _activeSession; if (oldItem != VSConstants.VSITEMID_NIL) { _window.ExpandItem(this, _activeSession, EXPANDFLAGS.EXPF_UnBoldItem); } _activeSession = node.ItemId; _window.ExpandItem(this, _activeSession, EXPANDFLAGS.EXPF_BoldItem); }
public void Ping(PingEvent e, SessionNode session) { float realtimeSinceStartup = UnityTime.realtimeSinceStartup; base.Log.InfoFormat("Ping e={0} pongCommandClientRealTime={1}", e, realtimeSinceStartup); PongEvent eventInstance = new PongEvent { PongCommandClientRealTime = realtimeSinceStartup, CommandId = e.CommandId }; base.ScheduleEvent(eventInstance, session); session.clientTime.PingServerTime = e.ServerTime; session.clientTime.PingClientRealTime = realtimeSinceStartup; }
static void Main(string[] args) { //Sodao.FastSocket.SocketBase.Log.Trace.EnableConsole(); //Sodao.FastSocket.SocketBase.Log.Trace.EnableDiagnostic(); var client = Sodao.Zookeeper.ZookClientPool.Get("zk1"); client.Register(new WatcherAction(e => { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.Path); Console.WriteLine(e.Type.ToString()); Console.WriteLine(e.State.ToString()); Console.ForegroundColor = ConsoleColor.Gray; })); Console.WriteLine("watch zk node /hong2..."); var watcher = new ChildrenWatcher(client, "/hong2", c => { Console.WriteLine(string.Join("-", c)); }); Console.WriteLine("create zk session node /hong2/tempABC..."); var sessionNode = new SessionNode(client, "/hong2/tempABC", null, IDs.OPEN_ACL_UNSAFE); Console.WriteLine("create zk node /hong2..."); NodeCreator.TryCreate(client, new NodeInfo("/hong2", null, IDs.OPEN_ACL_UNSAFE, CreateModes.Persistent)); Console.WriteLine("press any key stop thrift client..."); Console.ReadLine(); client.Stop(); Console.WriteLine("press any key start thrift client..."); Console.ReadLine(); client.Start(); Console.WriteLine("press any key dispose zk node(/hong2, /hong2/tempABC)..."); Console.ReadLine(); sessionNode.Dispose(); client.Delete("/hong2"); Console.WriteLine("press any key exit..."); Console.ReadLine(); }
/// <summary> /// new /// </summary> /// <param name="port"></param> /// <param name="serviceType"></param> /// <param name="zkConfigPath"></param> /// <param name="zkConfigName"></param> /// <param name="zNode"></param> /// <param name="owner"></param> public ZookeeperRegistry(int port, string serviceType, string zkConfigPath, string zkConfigName, string zNode, string owner) { if (string.IsNullOrEmpty(serviceType)) { throw new ArgumentNullException("serviceType"); } if (string.IsNullOrEmpty(zkConfigPath)) { throw new ArgumentNullException("zkConfigPath"); } if (string.IsNullOrEmpty(zkConfigName)) { throw new ArgumentNullException("zkConfigName"); } if (string.IsNullOrEmpty(zNode)) { throw new ArgumentNullException("zNode"); } this._zk = ZookClientPool.Get(zkConfigPath, "zookeeper", zkConfigName); this.RegisterZNode(new NodeInfo[] { new NodeInfo(string.Concat("/", zNode), null, IDs.OPEN_ACL_UNSAFE, CreateModes.Persistent), new NodeInfo(string.Concat("/", zNode, "/providers"), null, IDs.OPEN_ACL_UNSAFE, CreateModes.Persistent) }); this._sessionNode = new SessionNode(this._zk, string.Concat("/", zNode, "/providers/", Uri.EscapeDataString(string.Format( @"thrift2://{0}:{1}/{2}?anyhost=true&application={3}&dispatcher=message&dubbo=2.5.1& interface={2}&loadbalance=roundrobin&methods={7}&owner={4}&pid={5}&revision=0.0.2-SNAPSHOT& side=provider&threads=100×tamp={6}", IPUtility.GetLocalIntranetIP().ToString(), port.ToString(), zNode, Process.GetCurrentProcess().ProcessName, owner ?? "", Process.GetCurrentProcess().Id.ToString(), Date.ToMillisecondsSinceEpoch(DateTime.UtcNow).ToString(), string.Join(",", Type.GetType(serviceType).GetInterfaces()[0].GetMethods().Select(c => c.Name).ToArray())))), null, IDs.OPEN_ACL_UNSAFE); }
public void SetUid(NodeAddedEvent e, UidIndicatorNode uidIndicator, [JoinByScreen, Context] ScreenNode screen, [Context] SessionNode session) { uidIndicator.uidIndicator.Uid = session.restorePasswordUserData.Uid; }
/// <summary> /// Join a network session lobby /// </summary> /// <param name="username">The username the user wants.</param> /// <param name="ip">IP address</param> /// <paramm name="port">Port to join the host on and to host the server on</param> // TODO: Take in parameters from user private void JoinLobbySession(string username, string ip, int port) { SessionNode user = new SessionNode(username, ip, port); user.JoinSession(); }
public static Recording FromXml(string Xml) { XmlDocument Xdoc = new XmlDocument(); Xdoc.XmlResolver = null; Xdoc.LoadXml(Xml); string Name = ""; string Uname = ""; string Passwd = ""; string CsrfPara = ""; List <Session> Sessions = new List <Session>(); Request LoginChkReq = null; Response ResWhenLoggedIn = null; Response ResWhenLoggedOut = null; try { Name = Xdoc.SelectNodes("/xml/name")[0].InnerText; } catch { throw new Exception("Invalid Recording, name field is missing!"); } try { Uname = Tools.Base64Decode(Xdoc.SelectNodes("/xml/username")[0].InnerText); } catch { throw new Exception("Invalid Recording, username field is missing!"); } try { Passwd = Tools.Base64Decode(Xdoc.SelectNodes("/xml/password")[0].InnerText); } catch { throw new Exception("Invalid Recording, password field is missing!"); } try { CsrfPara = Tools.Base64Decode(Xdoc.SelectNodes("/xml/csrf_token")[0].InnerText); } catch { throw new Exception("Invalid Recording, CSRF token field is missing!"); } try { foreach (XmlNode SessionNode in Xdoc.SelectNodes("/xml/sessions/session")) { int LogId = Int32.Parse(SessionNode.SelectNodes("log_id")[0].InnerText.Trim()); Request Req = Request.FromBinaryString(SessionNode.SelectNodes("request")[0].InnerText.Trim()); Response Res = Response.FromBinaryString(SessionNode.SelectNodes("response")[0].InnerText.Trim()); Session Sess = new Session(LogId, Req, Res); Sessions.Add(Sess); } }catch { throw new Exception("Invalid recording, logs are corrupted."); } try { LoginChkReq = Request.FromBinaryString(Xdoc.SelectNodes("/xml/login_check_request")[0].InnerText); } catch { throw new Exception("Invalid recording, Login Check Request is missing."); } try { ResWhenLoggedIn = Response.FromBinaryString(Xdoc.SelectNodes("/xml/response_when_logged_in")[0].InnerText); } catch { throw new Exception("Invalid recording, Reference Response for logged in sessions is missing."); } try { ResWhenLoggedOut = Response.FromBinaryString(Xdoc.SelectNodes("/xml/response_when_logged_out")[0].InnerText); } catch { throw new Exception("Invalid recording, Reference Response for logged out sessions is missing."); } Analysis.LogAnalyzer Analyzer = new Analysis.LogAnalyzer(); Analysis.LogAssociations Assos = Analyzer.AnalyzeSessionsFromSameUa(Sessions); Recording FromDb = new Recording(Assos, Uname, Passwd, CsrfPara); FromDb.SetName(Name); FromDb.LoginCheckRequest = LoginChkReq; FromDb.LoginCheckResponseWhenLoggedIn = ResWhenLoggedIn; FromDb.LoginCheckResponseWhenLoggedOut = ResWhenLoggedOut; Analysis.LogAssociation LoginAsso = FromDb.LoginAssociations.GetLastAssociationWithParameterValues(new List <string>() { FromDb.Username, FromDb.Password }); if (LoginAsso == null) { throw new Exception("Invalid recording, unable to find login request in the login recording"); } FromDb.LoginRequestAsso = LoginAsso; return(FromDb); }
public void LogFirstGarageEntrance(NodeAddedEvent e, SingleNode <MainScreenComponent> homeScreen, [JoinAll] SessionNode session) { if (firstLoad) { firstLoad = false; base.ScheduleEvent <ClientGarageFirstLoadEvent>(session); } }
public void Set(NodeAddedEvent e, SessionNode session) { this.hasConnection = true; }
internal AutomationSession(SessionNode session) { _node = session; }
public void SendUserOnlineEvent(NodeAddedEvent e, UserOnlineNode userOnline, [JoinAll] SessionNode session) { base.ScheduleEvent <UserOnlineEvent>(session); }
/// <summary> /// new /// </summary> /// <param name="serviceType"></param> /// <param name="zkConfigPath"></param> /// <param name="zkConfigName"></param> /// <param name="zNode"></param> /// <param name="callback"></param> public ZoomkeeperDiscovery(string serviceType, string zkConfigPath, string zkConfigName, string zNode, Action <IPEndPoint[]> callback) { if (string.IsNullOrEmpty(serviceType)) { throw new ArgumentNullException("serviceType"); } if (string.IsNullOrEmpty(zkConfigPath)) { throw new ArgumentNullException("zkConfigPath"); } if (string.IsNullOrEmpty(zkConfigName)) { throw new ArgumentNullException("zkConfigName"); } if (string.IsNullOrEmpty(zNode)) { throw new ArgumentNullException("zNode"); } if (callback == null) { throw new ArgumentNullException("callback"); } this._callback = callback; this._zk = ZookClientPool.Get(zkConfigPath, "zookeeper", zkConfigName); this.RegisterZNode(new NodeInfo[] { new NodeInfo(string.Concat("/", zNode), null, IDs.OPEN_ACL_UNSAFE, CreateModes.Persistent), new NodeInfo(string.Concat("/", zNode, "/consumers"), null, IDs.OPEN_ACL_UNSAFE, CreateModes.Persistent) }); this._sessionNode = new SessionNode(this._zk, string.Concat("/", zNode, "/consumers/", Uri.EscapeDataString(string.Format( @"consumer://{0}/{1}?application={2}&category=consumers&check=false&dubbo=2.5.1& interface={1}&methods={6}&owner={3}&pid={4}&revision=0.0.2-SNAPSHOT& side=consumer×tamp={5}", IPUtility.GetLocalIntranetIP().ToString(), zNode, Process.GetCurrentProcess().ProcessName, string.Empty, Process.GetCurrentProcess().Id.ToString(), Date.ToMillisecondsSinceEpoch(DateTime.UtcNow).ToString(), string.Join(",", Type.GetType(serviceType).GetInterfaces()[0].GetMethods().Select(c => c.Name).ToArray())))), null, IDs.OPEN_ACL_UNSAFE); this._watcher = new ChildrenWatcher(this._zk, string.Concat("/", zNode, "/providers"), arrNodes => { this._callback(arrNodes.Select(c => { var objUri = new Uri(Uri.UnescapeDataString(c)); return(new IPEndPoint(IPAddress.Parse(objUri.Host), objUri.Port)); }).ToArray()); //lock (this._lockObj) //{ // var arrExists = this._thrift.GetAllRegisteredEndPoint().Select(c => c.Key).Distinct().ToArray(); // var arrCurr = arrNodes.Select(node => // { // var strUrl = Uri.UnescapeDataString(node); // strUrl = strUrl.Substring(strUrl.IndexOf(":") + 3); // return strUrl.Substring(0, strUrl.IndexOf("/")); // }).ToArray(); // var set = new HashSet<string>(arrExists); // set.ExceptWith(arrCurr); // if (set.Count > 0) // { // foreach (var child in set) // this._thrift.UnRegisterEndPoint(child); // } // set = new HashSet<string>(arrCurr); // set.ExceptWith(arrExists); // if (set.Count > 0) // { // foreach (var child in set) // { // var i = child.IndexOf(":"); // var endpoint = new IPEndPoint(IPAddress.Parse(child.Substring(0, i)), int.Parse(child.Substring(i + 1))); // this._thrift.TryRegisterEndPoint(child, new EndPoint[] { endpoint }); // } // } //} }); }
public void ValidLogin(NodeAddedEvent e, ValidLoginFieldNode login, [JoinAll] SessionNode session) { base.ScheduleEvent(new IncrementRegistrationNicksEvent(login.inputField.Input), session); }
public void SendClientInfoStatistics(NodeAddedEvent e, UserOnlineNode userNode, [JoinAll] SessionNode session, Optional <SingleNode <SteamMarkerComponent> > steamNode) { ClientInfo info = new ClientInfo { deviceModel = SystemInfo.deviceModel, deviceName = SystemInfo.deviceName, deviceType = SystemInfo.deviceType.ToString(), deviceUniqueIdentifier = SystemInfo.deviceUniqueIdentifier, graphicsDeviceName = SystemInfo.graphicsDeviceName, graphicsDeviceVendor = SystemInfo.graphicsDeviceVendor, graphicsDeviceVersion = SystemInfo.graphicsDeviceVersion, graphicsDeviceID = SystemInfo.graphicsDeviceID, graphicsDeviceType = SystemInfo.graphicsDeviceType.ToString(), graphicsDeviceVendorID = SystemInfo.graphicsDeviceVendorID, graphicsMemorySize = SystemInfo.graphicsMemorySize, graphicsShaderLevel = SystemInfo.graphicsShaderLevel, operatingSystem = SystemInfo.operatingSystem, systemMemorySize = SystemInfo.systemMemorySize, processorType = SystemInfo.processorType, processorCount = SystemInfo.processorCount, processorFrequency = SystemInfo.processorFrequency, supportsLocationService = SystemInfo.supportsLocationService, qualityLevel = QualitySettings.GetQualityLevel(), resolution = Screen.currentResolution.ToString(), dpi = Screen.dpi, entranceSource = (!steamNode.IsPresent() ? 0 : 1).ToString() }; base.ScheduleEvent(new ClientInfoSendEvent(JsonUtility.ToJson(info)), session); }
public void InvalidPasswordRepeat(NodeAddedEvent e, InvalidPasswordRepeatFieldNode password, [JoinAll] SessionNode session) { base.ScheduleEvent <InvalidRegistrationPasswordEvent>(session); }
public void SendUserQuestReadyEvent(NodeAddedEvent e, UserQuestReadyNode userNode, [JoinAll] SessionNode session) { base.ScheduleEvent <UserQuestReadyEvent>(session); }