public override void _Ready() { network = new Network.Network(GetTree()); AddChild(network); if (OS.GetEnvironment("DEDICATED_SERVER") == "true" || OS.GetName() == "Server") { GD.Print("Attempting to start server..."); network.StartServer(); } else { GD.Print("Attempting to start client..."); network.StartClient(); } }
static void Main(string[] args) { ReadOut input = new ReadOut("..\\..\\inform.txt"); Network network = new Network(input, 38); while (true) { var key = Console.ReadKey(true); switch (key.Key) { case ConsoleKey.Enter: Console.Clear(); Console.WriteLine(network.GetInformation()); network.OneTact(); break; } } }
protected override void OnStart(string[] args) { try { log.Info("Service Started"); var ip1 = ConfigurationManager.AppSettings["IpV4Filter1"] == string.Empty ? null : ConfigurationManager.AppSettings["IpV4Filter1"]; var ip2 = ConfigurationManager.AppSettings["IpV4Filter2"] == string.Empty ? null : ConfigurationManager.AppSettings["IpV4Filter2"]; var ip3 = ConfigurationManager.AppSettings["IpV4Filter3"] == string.Empty ? null : ConfigurationManager.AppSettings["IpV4Filter3"]; var ip4 = ConfigurationManager.AppSettings["IpV4Filter4"] == string.Empty ? null : ConfigurationManager.AppSettings["IpV4Filter4"]; var port = ConfigurationManager.AppSettings["IpV4Port"] == string.Empty ? "6666" : ConfigurationManager.AppSettings["IpV4Port"]; var pluginPath = ConfigurationManager.AppSettings["PluginPath"] == string.Empty ? null : ConfigurationManager.AppSettings["PluginPath"]; var msiFilePath = ConfigurationManager.AppSettings["MsiFilePath"] == string.Empty ? null : ConfigurationManager.AppSettings["MsiFilePath"]; var serverUrl = ConfigurationManager.AppSettings["ServerUrl"] == string.Empty ? null : ConfigurationManager.AppSettings["ServerUrl"]; var msiFileServerUrl = ConfigurationManager.AppSettings["MsiFileServerUrl"] == string.Empty ? null : ConfigurationManager.AppSettings["MsiFileServerUrl"]; var dllFileServerUrl = ConfigurationManager.AppSettings["DllFileServerUrl"] == string.Empty ? null : ConfigurationManager.AppSettings["DllFileServerUrl"]; var ConfgiFileServerUrl = ConfigurationManager.AppSettings["ConfigFileServerUrl"] == string.Empty ? null : ConfigurationManager.AppSettings["ConfigFileServerUrl"]; //ConfigFileServerUrl var network = new Network.Network(new IpV4Filter() { Ip1 = ip1, Ip2 = ip2, Ip3 = ip3, Ip4 = ip4 }, new Models.Configs.HttpServerConfigs() { PluginPath = pluginPath, MsiFilePath = msiFilePath, Port = port, ServerUrl = serverUrl, MsiFileServerUrl = msiFilePath, DllFileServerUrl = dllFileServerUrl, ConfigFileServerUrl = ConfgiFileServerUrl }); Thread serverThread = new Thread(new ThreadStart(network.StartHttpServer)); serverThread.Start(); // network.StartHttpServer(); } catch (Exception e) { log.Error(e.Message); log.Error(e.StackTrace); } }
protected override void ProcessMessage(byte[] buffer, Network.MessageType type) { string[] message = Encoding.ASCII.GetString(buffer).Split(' '); if (message[0] == "start") { Webcam w = (Webcam)_dvPresenter.FindDevice(message[1]); if (w != null) { w.AddClient(this); EventArg = "Client " + Name + " requested webcam " + w.Name; RaiseWebcamChangeEvent(); } } else if (message[0] == "stop") { Webcam w = (Webcam)_dvPresenter.FindDevice(message[1]); if (w != null) { w.RemoveClient(this); EventArg = "Client " + Name + " stopped viewing webcam " + w.Name; RaiseWebcamChangeEvent(); } } else if (message[0] == "get-list") { string wcList = "webcam-list"; foreach (string s in _dvPresenter.GetWebcamNames()) wcList += " " + s; SendMessage(wcList); } }
public void Initialize() { ReadOut input = new ReadOut("..\\..\\test.txt"); network = new Network.Network(input, 38); }