// initialize servers public static void Initialize() { Dynamic = new DynamicServer(); Plugins = new PluginServer(); try { // initialize dynamic servers Dynamic.Initialize(""); Dynamic.ProxyAddress = Config.Local.ProxyAddress; Dynamic.UseProxy = Config.Local.UseProxy; } catch { } try { // initialized plugin servers Plugins.Initialize(""); Plugins.ProxyAddress = Config.Local.ProxyAddress; Plugins.UseProxy = Config.Local.UseProxy; } catch { } // mark initialization flag initialized = true; }
public static void Main(string[] args) { var log = new ConsoleLog(); using (var requestQueue = new RequestQueue()) { var server = new PluginServer(log, requestQueue); server.Start(); while (true) { while (requestQueue.Requests.TryDequeue(out Request request)) { log.WriteLine("dequeued: " + request.Message); requestQueue.Replys.Add( new Request(request.ClientStream, $"Got {request.Message.Length} bytes, thanks!")); } Thread.Sleep(50); } // server.Start(waitForFinish: true); } }
public static OutputPanel[] GetOutputPanels(string panelTitle) { return((from pic in PluginServer.GetExistingControls() select pic.OutputPanel into p where p.Heading == panelTitle select p).ToArray <OutputPanel>()); }
public IvxrPluginContext() { var seLog = new SeLog(alwaysFlush: true); seLog.Init("ivxr-plugin.log"); Log = seLog; var sessionController = new SessionController() { Log = Log }; m_sessionDispatcher = new SessionDispatcher(sessionController) { Log = Log }; m_server = new PluginServer(Log, m_sessionDispatcher, m_requestQueue); var observer = new Observer(m_gameSession); var controller = new CharacterController(m_gameSession); Dispatcher = new Dispatcher(m_requestQueue, observer, controller) { Log = Log }; }
/// <summary>加载完成后</summary> protected override void OnLoaded() { if (TempPath.IsNullOrEmpty()) { if (Runtime.IsWeb) { TempPath = "..\\XTemp"; } else { TempPath = "XTemp"; } } #if !__MOBILE__ if (PluginCache.IsNullOrWhiteSpace()) { // 兼容Linux Mono var sys = Environment.SystemDirectory; if (sys.IsNullOrEmpty()) { sys = "/"; } PluginCache = Path.GetPathRoot(sys).CombinePath("X", "Cache"); } #endif if (PluginServer.IsNullOrWhiteSpace() || PluginServer.StartsWithIgnoreCase("ftp://")) { PluginServer = "http://x.newlifex.com/"; } base.OnLoaded(); }
/// <summary>加载完成后</summary> protected override void OnLoaded() { if (LogPath.IsNullOrEmpty()) { LogPath = "Log"; } if (DataPath.IsNullOrEmpty()) { DataPath = "Data"; } if (BackupPath.IsNullOrEmpty()) { BackupPath = "Backup"; } if (LogFileFormat.IsNullOrEmpty()) { LogFileFormat = "{0:yyyy_MM_dd}.log"; } if (PluginServer.IsNullOrWhiteSpace()) { PluginServer = "http://x.newlifex.com/"; } base.OnLoaded(); }
public static OutputPanel DisplayControl(Control c, string panelTitle) { PluginControl control = PluginServer.AddControl(c, panelTitle); if (control == null) { return(null); } return(control.OutputPanel); }
static async Task Main(string[] args) { var server = new PluginServer(listenHost, listenPort, appProtoVersion); server.Health.SetStatus("plugin", HealthStatus.Serving); server.Services.Add(Proto.KV.BindService(new KVImpl())); server.Start(); await server.WriteHandshakeAsync(); Console.WriteLine("Hit a key to exit..."); Console.ReadKey(); Console.WriteLine("...shutting down..."); await server.ShutdownAsync(); }
public void ProcessRequest(RequestItem request) { try { var requestShell = m_jsoner.ToObject <SeRequestShell <SessionCommand> >(request.Message); m_sessionController.LoadScenario(requestShell.Arg.ScenarioPath); PluginServer.ReplyOK(request.ClientStream); } catch (Exception ex) { Log.Exception(ex, "Error processing a request"); Log.WriteLine($"Full request: \"{request.Message}\""); PluginServer.ReplyFalse(request.ClientStream); // Simple error response, details can be learned from the log. } }
public static void Main(string[] args) { var log = new ConsoleLog(); var sessionController = new MockSessionController() { Log = log }; var sessionDispatcher = new SessionDispatcher(sessionController) { Log = log }; using (var requestQueue = new RequestQueue()) { var server = new PluginServer(log, sessionDispatcher, requestQueue); server.Start(); var observer = new MockObserver(); var controller = new MockCharacterController() { Log = log }; var dispatcher = new Dispatcher(requestQueue, observer, controller); dispatcher.Log = log; while (true) { dispatcher.ProcessRequests(); /* * while (requestQueue.Requests.TryDequeue(out Request request)) * { * log.WriteLine("dequeued: " + request.Message); * * requestQueue.Replies.Add( * new Request(request.ClientStream, $"Got {request.Message.Length} bytes, thanks!")); * } */ Thread.Sleep(5); } // server.Start(waitForFinish: true); } }
/// <summary>加载完成后</summary> protected override void OnLoaded() { #if !Android if (PluginCache.IsNullOrWhiteSpace()) { // 兼容Linux Mono var sys = Environment.SystemDirectory; if (sys.IsNullOrEmpty()) { sys = "/"; } PluginCache = Path.GetPathRoot(sys).CombinePath("X", "Cache"); } #endif if (PluginServer.IsNullOrWhiteSpace()) { PluginServer = "http://www.newlifex.com/showtopic-51.aspx"; } base.OnLoaded(); }
/// <summary>加载完成后</summary> protected override void OnLoaded() { #if !__MOBILE__ if (PluginCache.IsNullOrWhiteSpace()) { // 兼容Linux Mono var sys = Environment.SystemDirectory; if (sys.IsNullOrEmpty()) { sys = "/"; } PluginCache = Path.GetPathRoot(sys).CombinePath("X", "Cache"); } #endif if (PluginServer.IsNullOrWhiteSpace() || PluginServer.EqualIgnoreCase("http://x.newlifex.com/")) { PluginServer = "ftp://ftp.newlifex.com/x/"; } base.OnLoaded(); }
/// <summary>加载完成后</summary> protected override void OnLoaded() { var web = Runtime.IsWeb; if (LogPath.IsNullOrEmpty()) { LogPath = web ? "..\\Log" : "Log"; } if (TempPath.IsNullOrEmpty()) { TempPath = web ? "..\\XTemp" : "XTemp"; } if (LogFileFormat.IsNullOrEmpty()) { LogFileFormat = "{0:yyyy_MM_dd}.log"; } #if !__MOBILE__ if (PluginCache.IsNullOrWhiteSpace()) { // 兼容Linux Mono var sys = Environment.SystemDirectory; if (sys.IsNullOrEmpty()) { sys = "/"; } PluginCache = Path.GetPathRoot(sys).CombinePath("X", "Cache"); } #endif if (PluginServer.IsNullOrWhiteSpace() || PluginServer.StartsWithIgnoreCase("ftp://")) { PluginServer = "http://x.newlifex.com/"; } base.OnLoaded(); }
private void InitializeOpenedWindow() { IsShown = true; InstanceManager.PushTabBarInstance(this); InstallHooks(); pluginServer = new PluginServer(this); if(!TryCallButtonBar(bbar => bbar.CreateItems())) { // Try again in 2 seconds Timer timer = new Timer { Interval = 2000 }; timer.Tick += (sender, args) => { TryCallButtonBar(bbar => bbar.CreateItems()); timer.Stop(); }; timer.Start(); } if(QTUtility.WindowAlpha < 0xff) { PInvoke.SetWindowLongPtr(ExplorerHandle, -20, PInvoke.Ptr_OP_OR(PInvoke.GetWindowLongPtr(ExplorerHandle, -20), 0x80000)); PInvoke.SetLayeredWindowAttributes(ExplorerHandle, 0, QTUtility.WindowAlpha, 2); } listViewManager = new ListViewMonitor(ShellBrowser, ExplorerHandle, Handle); listViewManager.ListViewChanged += ListViewMonitor_ListViewChanged; listViewManager.Initialize(); IntPtr hwndBreadcrumbBar = WindowUtils.FindChildWindow(ExplorerHandle, hwnd => PInvoke.GetClassName(hwnd) == "Breadcrumb Parent"); if(hwndBreadcrumbBar != IntPtr.Zero) { hwndBreadcrumbBar = PInvoke.FindWindowEx(hwndBreadcrumbBar, IntPtr.Zero, "ToolbarWindow32", null); if(hwndBreadcrumbBar != IntPtr.Zero) { breadcrumbBar = new BreadcrumbBar(hwndBreadcrumbBar); breadcrumbBar.ItemClicked += FolderLinkClicked; } } }
public static OutputPanel[] GetOutputPanels() { return((from pic in PluginServer.GetExistingControls() select pic.OutputPanel).ToArray <OutputPanel>()); }
public static OutputPanel GetOutputPanel(string panelTitle) { return((from pic in PluginServer.GetExistingControls() select pic.OutputPanel).FirstOrDefault <OutputPanel>(p => (p.Heading == panelTitle))); }
public static async Task <PluginServer> RunService(Assembly pluginAssembly = null) { var tfRunId = Environment.GetEnvironmentVariable("TF_RUN_ID"); _log.LogInformation("###############################################################"); _log.LogInformation("TF Plugin Server Starting up..."); if (!string.IsNullOrEmpty(tfRunId)) { _log.LogInformation($"TF Run ID: {tfRunId}"); } // For debugging/troubleshooting: // _log.LogInformation("ENV: " + string.Join("\n", Environment.GetEnvironmentVariables() // .Cast<System.Collections.DictionaryEntry>() // .Select(x => $"{x.Key}={x.Value}"))); var magic = System.Environment.GetEnvironmentVariable(HandshakeMagicCookieName); if (HandshakeMagicCookieValue != magic) { throw new Exception("plugin should only be invoked by host"); } if (!int.TryParse(Environment.GetEnvironmentVariable(MinPortName), out var minPort)) { minPort = _listenPort; } if (!int.TryParse(Environment.GetEnvironmentVariable(MaxPortName), out var maxPort)) { maxPort = _listenPort + 100; } _listenPort = FindFreePort(minPort, maxPort); if (_listenPort <= 0) { throw new Exception("could not find a free listening port in the requested range"); } _tls = TLSConfigSimple.GenerateSelfSignedRSA(); _log.LogInformation("listen host: {@listenHost}", _listenHost); _log.LogInformation("listen ports: {@minPort}-{@maxPort} : {@listenPort}", minPort, maxPort, _listenPort); var server = new PluginServer(_listenHost, _listenPort, _appProtoVersion, _tls); var provider = new ProviderImpl(pluginAssembly); server.Services.Add(ProviderImpl.BindService(provider)); server.Health.SetStatus("plugin", HealthStatus.Serving); server.Start(); await server.WriteHandshakeAsync(); Console.WriteLine("Hit a key to exit..."); Console.ReadKey(); Console.WriteLine("...shutting down..."); _log.LogInformation("Shutting down..."); await server.ShutdownAsync(); _log.LogInformation("Stopped."); _log.LogInformation("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); return(server); }