static void Main() { ElasticSearchCommands.Populate(); ConnectServer c = new ConnectServer(); Thread cServer = new Thread(() => c.StartServer()); cServer.Start(); Thread energy_update = new Thread(() => ElasticSearchCommands.UpdateEnergy()); //Set boolean to true to run bot clients bool bot_test = false; if (bot_test) { List <Thread> thread_list = new List <Thread>(); for (int i = 0; i < 1; i++) { thread_list.Add(new Thread(() => ElasticSearchCommands.BotBehaviour(ElasticSearchCommands.CreateBotShip((i + 20).ToString())))); thread_list[i].Start(); Thread.Sleep(500); } } energy_update.Start(); Console.WriteLine("Pass"); }
public AccountHelper() { helper = new HtmlHelper(); Server = new ConnectServer(); appSetting = new AppSettingModel(); loginValue = ApplicationData.Current.LocalSettings; }
public void cerrarAPP() { ConnectServer connection = new ConnectServer(); connection.CloseServer(); Application.Quit(); }
public int MaxActiveClientCount = 10000; //todo провверить корректность дисконнекта public void Start(string path, int port = SessionClient.DefaultPort) { var rep = Repository.Get; rep.SaveFileName = Path.Combine(path, "World.dat"); rep.Load(); //общее обслуживание rep.Timer.Add(1000, DoWorld); //сохранение, если были изменения rep.Timer.Add(10000, () => { rep.Save(true); }); ActiveClientCount = 0; if (LogMessage != null) { LogMessage("Start server in port " + port.ToString()); } Connect = new ConnectServer(); Connect.ConnectionAccepted = ConnectionAccepted; Connect.Start(null, port); }
public PlayReactor?Connect() { TcpClient client = localPort is int port ? new TcpClient(new IPEndPoint(IPAddress.Any, port)) : new TcpClient(); console.Output.WriteLine($"Connecting to {ipAddress}:{this.port}..."); client.Connect(new IPEndPoint(ipAddress, this.port)); console.Output.WriteLine("Connected!"); TCPMessageSender messageSender = new TCPMessageSender(client.GetStream()); messageSender.QueueMessage(new ConnectClient()); console.Output.WriteLine("Hailing server..."); messageSender.SendOneMessage(); TCPMessagePasser messagePasser = new TCPMessagePasser(client.GetStream(), this); while (!serverState.HasValue) { console.Output.WriteLine("Listening for response..."); messagePasser.ListenAndReactClient(); } ConnectServer ss = serverState.Value; if (ss.CanHost) { return(new PlayReactor(client, ss)); } else { return(null); } }
public void ConnectServerCmdlet() { var connect = new ConnectServer { ServerName = "TPSCCM.yevrag35.com" }; Assert.IsTrue(connect.Invoke <object>().Count() == 0); Thread.Sleep(2000); var disconnect = new DisconnectServer(); Assert.IsTrue(disconnect.Invoke <object>().Count() == 0); Thread.Sleep(500); connect.EncryptConnection = true; connect.Force = true; Assert.IsTrue(connect.Invoke <object>().Count() == 0); Thread.Sleep(2000); disconnect.Invoke(); }
private void ConnectDB() { while (true) { ConnectServer server = new ConnectServer(); DialogResult result = server.ShowDialog(); if (result == DialogResult.OK) { fileUpDate = File.GetLastWriteTime(ReadXML.XmlFileName); try { this.Reconnect(); break; } catch (Exception ex) { MessageBox.Show("数据库连接失败,请重新配置数据库连接!\r\n" + ex.ToString()); } } else { break; } } }
public void Server_Unknown_Command() { String test_command = "test"; String test_User = "******"; String result = ConnectServer.AddCommand(test_command, test_User); Assert.AreEqual("Unknown command: (" + test_command + ") \n Please try again.", result); }
public void Server_GetHealth_Command() { String test_command = "GetHealth"; String test_User = "******"; String result = ConnectServer.AddCommand(test_command, test_User); Assert.AreEqual("Current health: 100", result); }
public void Server_GetEnergy_Command() { String test_command = "GetEnergy"; String test_User = "******"; String result = ConnectServer.AddCommand(test_command, test_User); Assert.AreEqual("Current energy: 100", result); }
public HtmlHelper() { Server = new ConnectServer(); appSetting = new AppSettingModel(); defineEmoticon = new DefineEmoticon(); EasClientDvInfo = new EasClientDeviceInformation(); GetTemplateHTML(); }
public void Server_AddCommand() //also acts as a test for the exit command { String test_command = "exit"; String test_User = "******"; String result = ConnectServer.AddCommand(test_command, test_User); Assert.AreEqual("Quitting game!", result); }
//关闭当前连接 public void Close() { if (m_Client != null) { m_Client.Close(); m_Client = null; } }
public ListStaff() { InitializeComponent(); staffController = new StaffController(); initCommon(); conn = new ConnectServer(Constants.server, Constants.user, Constants.password); initListStaff(); }
public void SerializeAndDeSerializeConnectServerMessages() { ConnectServer connect = new ConnectServer(true, playerIntegerSize, 0, 1); byte[] bytes = Serializer.Serialize(connect, 0); ConnectServer message = (ConnectServer)Serializer.DeSerializeClient(bytes, 0); Assert.AreEqual(connect, message, "Should be able to serialize and deserialize the connect server message."); }
// Use this for initialization void Start() { Q1 = GameObject.Find("Q1").GetComponent <Text>(); Q2 = GameObject.Find("Q2").GetComponent <Text>(); Q3 = GameObject.Find("Q3").GetComponent <Text>(); Q4 = GameObject.Find("Q4").GetComponent <Text>(); Q5 = GameObject.Find("Q5").GetComponent <Text>(); result = GameObject.Find("result"); connectServer = GameObject.Find("SceneController").GetComponent <ConnectServer>(); }
public PlayReactor(TcpClient client, ConnectServer ss) { playerId = ss.PlayerId; this.client = client; messagePasser = new TCPMessagePasser(this.client.GetStream(), this); messagePasser.PlayerIntegerSize = ss.PlayerIntegerSize; messageSender = new TCPMessageSender(this.client.GetStream()); messageSender.PlayerIntegerSize = ss.PlayerIntegerSize; main = new MainComponent(); }
void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); Transform lastActiveButton = activeButton; activeButton = null; if (lastActiveButton != null) { lastActiveButton.GetComponent <Renderer>().material.color = Color.white; } if (Physics.Raycast(ray, out hit, 100.0f, ButtonLayer)) { if (hit.transform.CompareTag("Button")) { activeButton = hit.transform; activeButton.GetComponent <Renderer>().material.color = new Color(0.0f, 0.378f, 1.0f); int _ID = (int)hit.transform.GetComponent <KeyType>().ButtonID; if (Input.GetButtonDown("Fire1")) { if (_ID < 10) { severIpAddress += _ID.ToString(); } else if (_ID == 10) { severIpAddress += "."; } else if (_ID == 11) { if (severIpAddress.Length > 0) { severIpAddress = severIpAddress.Substring(0, severIpAddress.Length - 1); } } else if (_ID == 12) { IPStream _ipWriter = new IPStream(); _ipWriter.WriteIP(severIpAddress); ConnectServer.ConnectToServer(severIpAddress); } IpText.GetComponent <TextMesh>().text = severIpAddress; //Debug.Log(severIpAddress); } } } }
// Use this for initialization void Start() { otherNetBuffer = new byte[1024]; recoBuffer = new byte[1024]; connectManager = GameObject.FindGameObjectWithTag("CONNECT"); if (connectManager == null) { connectManager = (GameObject)Instantiate(Resources.Load("ConnectManager")); } cs = connectManager.GetComponent <ConnectServer> (); socket = cs.socket; tempHeader = new Header(); startBuffer = new byte[tempHeader.startSize]; }
public void Start(string path, int port = SessionClient.DefaultPort) { if (!File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "Settings.json"))) { ServerSettings = new ServerSettings(); ServerSettings.Port = port; using (StreamWriter file = File.CreateText(Path.Combine(path, "Settings.json"))) { JsonSerializer serializer = new JsonSerializer(); serializer.Formatting = Formatting.Indented; serializer.Serialize(file, ServerSettings); } } else { ServerSettings = JsonConvert.DeserializeObject <ServerSettings>(File.ReadAllText(Path.Combine(path, "Settings.json"))); } Loger.PathLog = path; Loger.IsServer = true; Loger.Log($"Server starting on port: {ServerSettings.Port}"); var rep = Repository.Get; rep.SaveFileName = Path.Combine(path, "World.dat"); rep.Load(); //общее обслуживание rep.Timer.Add(1000, DoWorld); //сохранение, если были изменения rep.Timer.Add(ServerSettings.SaveInterval, () => { rep.Save(true); }); ActiveClientCount = 0; Connect = new ConnectServer(); Connect.ConnectionAccepted = ConnectionAccepted; Connect.Start(null, ServerSettings.Port); }
/// <summary> /// 处理连接服务器消息 --注意:此版本已不用这个消息,保留是为了兼容前面的版本 /// </summary> /// <param name="message"></param> private void HandleConnectServer(string message) { //try //{ ConnectServer Data = (ConnectServer)XmlUtil.Deserialize(typeof(ConnectServer), message); string ZXIT_JSKF_TEST = Data.CommandID; if (ZXIT_JSKF_TEST == "ConnectServer") { string xml = XmlUtil.GetXMlStart() + "<ZXEMC><CommandID>ConnectServerResp</CommandID><ConnectResult>1</ConnectResult><FailtureReason></FailtureReason></ZXEMC>"; ServerClient.SendMessage(xml); } else { string xml = XmlUtil.GetXMlStart() + "<ZXEMC><CommandID>ConnectServerResp</CommandID><ConnectResult>0</ConnectResult><FailtureReason>网络单元连接服务器名称不正确</FailtureReason></ZXEMC>"; ServerClient.SendMessage(xml); } //} // catch (Exception ex) { LogHelper.WriteLog("" , ex); } }
private void connect_server_thread(object player_name) { ConnectServer conn = new ConnectServer(); int conn_result = conn.connect_server((string)player_name); if (conn_result == 1) { this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { connect_message_block.Text = "Player full! Please try later."; }); } else if (conn_result == 0) { this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { Start_Interface.Visibility = Visibility.Hidden; Game_Interface.Visibility = Visibility.Visible; my_id = conn.get_player_id(); player_name_blocks[my_id].Text = user_name_input_box.Text; player_name_blocks[my_id].Foreground = new SolidColorBrush(Colors.Black); player_score_blocks[my_id].Foreground = new SolidColorBrush(Colors.Black); }); server_socket = conn.get_socket(); socket_using = true; receive_message_thread.Start(); } else { this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { connect_message_block.Text = "Connect wrong! Please try later."; }); } }
public void Start() { var rep = Repository.Get; //общее обслуживание rep.Timer.Add(1000, DoWorld); //сохранение, если были изменения rep.Timer.Add(ServerSettings.SaveInterval, () => { rep.Save(true); }); //ServerManager.ServerSettings.AutoSaveStatisticsFile SavePlayerStatisticsFile() //ActiveClientCount = 0; Connect = new ConnectServer(); Connect.ConnectionAccepted = ConnectionAccepted; Loger.Log($"Server starting on port: {ServerSettings.Port}"); Connect.Start(null, ServerSettings.Port); }
public async void LoginMethod(string userName, string passWord, Boolean save) { try { string contentHtml = string.Empty; ConnectServer.Login(userName, passWord, ref contentHtml); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(contentHtml); StringReader reader = new StringReader(doc.DocumentNode.OuterHtml); string result = reader.ReadToEnd(); //Get token. string token = Regex.Match(result, "SECURITYTOKEN = \".+\"").Value + Environment.NewLine; token = Regex.Match(token, "\".+\"").Value; token = token.Remove(0, 1); token = token.Remove(token.Length - 1, 1); //Get user ID string user_id = ""; if (result.Contains("Welcome, <a href=\"member.php?u=")) { int startIndex = result.IndexOf("Welcome, <a href=\"member.php?u=") + 31; for (int i = startIndex; i < result.Count(); i++) { if (result[i] == '"') { user_id = result.Substring(startIndex, i - startIndex); break; } } } //Check Posts int checkPost = await helper.GetPosts(int.Parse(user_id)); appSetting.UserName = userName; appSetting.PassWord = passWord; appSetting.token = token; appSetting.UserId = user_id; if (save) { appSetting.SaveState = "true"; } else { loginValue.Values["saveState"] = "false"; } if (checkPost >= 20) { appSetting.CheckPosts = "Ok"; } else { appSetting.CheckPosts = "NotOk"; } if (token == "guest") { showlog(); appSetting.UserName = ""; appSetting.PassWord = ""; } } catch { } }
public StaffController() { conn = new ConnectServer(Constants.server, Constants.user, Constants.password); }
public MaterialController() { conn = new ConnectServer(Constants.server, Constants.user, Constants.password); }
public void ReceiveConnect(ConnectServer message) { serverState = message; }
static void Main() { const string applicationName = "TotalSmartCodingSolution"; bool createdNew; mutex = new Mutex(true, applicationName, out createdNew); if (!createdNew) { return; } //app is already running! Exiting the application Registries.ProductName = Application.ProductName.ToUpper(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AutoMapperConfig.SetupMappings(); //string ApplicationRoleRequired = "false"; //COMMENT ON 11-JUL-2018: NOT USE ApplicationRoleRequired. JUST REMOVE THIS COMMENT ONLY -> TO USE ApplicationRoleRequired (GET ApplicationRoleRequired OPTION FROM CONFIG SETTING BY THE FOLLOWING CommonConfigs.ReadSetting("ApplicationRoleRequired")). string ApplicationRoleRequired = CommonConfigs.ReadSetting("ApplicationRoleRequired"); ApplicationRoles.Required = true; ApplicationRoles.Name = ""; ApplicationRoles.Password = ""; bool applicationRoleRequired = false; if (bool.TryParse(ApplicationRoleRequired, out applicationRoleRequired)) { ApplicationRoles.Required = applicationRoleRequired; } TrialConnects trialConnects = new TrialConnects(); DialogResult trialConnectResult = trialConnects.Connected(); if (trialConnectResult == DialogResult.Yes) { Logon logon = new Logon(); if (logon.ShowDialog() == DialogResult.OK) { if (!GlobalEnums.CBPP) { LegalNotice legalNotice = new LegalNotice(); legalNotice.ShowDialog(); legalNotice.Dispose(); } if (GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Smallpack || GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Pail || GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Medium4L || GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Import || GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Drum) { Application.Run(new MasterMDI(GlobalEnums.NmvnTaskID.SmartCoding, new SmartCoding())); } else { if (GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Pickup) { Application.Run(new MasterMDI(GlobalEnums.NmvnTaskID.Pickups, new Pickups())); } else if (GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.GoodsIssue) { Application.Run(new MasterMDI(GlobalEnums.NmvnTaskID.GoodsIssues, new GoodsIssues())); } else { Application.Run(new MasterMDI()); } } } logon.Dispose(); } else if (trialConnectResult == DialogResult.No) { if (ApplicationRoles.Required) { ConnectServer connectServer = new ConnectServer(false); connectServer.ShowDialog(); connectServer.Dispose(); } else if (CustomMsgBox.Show(new Form(), "Do you want to specify new application role and password?", "Warning", MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { ConnectServer connectServer = new ConnectServer(true); connectServer.ShowDialog(); connectServer.Dispose(); } } }
void _init() { m_Client = new ConnectServer(); }
public void Start(string path) { //var jsonFile = Path.Combine(Directory.GetCurrentDirectory(), "Settings.json"); var jsonFile = Path.Combine(path, "Settings.json"); if (!File.Exists(jsonFile)) { using (StreamWriter file = File.CreateText(jsonFile)) { var jsonText = JsonSerializer.Serialize(ServerSettings, new JsonSerializerOptions() { WriteIndented = true }); file.WriteLine(jsonText); } Console.WriteLine("Created Settings.json, server was been stopped"); Console.WriteLine($"RU: Настройте сервер, заполните {jsonFile}"); Console.WriteLine("Enter some key"); Console.ReadKey(); return; } else { try { using (var fs = new StreamReader(jsonFile, Encoding.UTF8)) { var jsonString = fs.ReadToEnd(); ServerSettings = JsonSerializer.Deserialize <ServerSettings>(jsonString); } ServerSettings.WorkingDirectory = path; var results = new List <ValidationResult>(); var context = new ValidationContext(ServerSettings); if (!Validator.TryValidateObject(ServerSettings, context, results, true)) { foreach (var error in results) { Console.WriteLine(error.ErrorMessage); Loger.Log(error.ErrorMessage); } Console.ReadKey(); return; } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine($"RU: Проверьте настройки сервера {jsonFile}"); Console.WriteLine("EN: Check Settings.json"); Console.ReadKey(); return; } } MainHelper.OffAllLog = false; Loger.PathLog = path; Loger.IsServer = true; var rep = Repository.Get; rep.SaveFileName = Path.Combine(path, "World.dat"); rep.Load(); CheckDiscrordUser(); createFilesDictionary(); //общее обслуживание rep.Timer.Add(1000, DoWorld); //сохранение, если были изменения rep.Timer.Add(ServerSettings.SaveInterval, () => { rep.Save(true); }); //ActiveClientCount = 0; Connect = new ConnectServer(); Connect.ConnectionAccepted = ConnectionAccepted; Loger.Log($"Server starting on port: {ServerSettings.Port}"); Connect.Start(null, ServerSettings.Port); }