public void If_Server_Cant_Attack_One_Networkcontroller_Twice() { Mock <IHumanPlayer> humanmock = new Mock <IHumanPlayer>(); IServerNetworkController server = new ServerObject(humanmock.Object, 40, 0, 0, 40); INetworkController target = new ServerObject(10, 125, 25, 100); server.Attack(target); server.Attack(target); Assert.That(server.Utps.Count == 1); }
public Player(ServerObject game) : base(game) { anim1 = new SpriteIDs[3]{ SpriteIDs.Player1_anim1_frame1, SpriteIDs.Player1_anim1_frame2, SpriteIDs.Player1_anim1_frame3 }; sprites.Add("ground", new ClientSprite(SpriteIdGenerator.getId(), new Vector2(0, 50), 0f, SpriteIDs.platform1)); sprites.Add("body", new ClientSprite(SpriteIdGenerator.getId(), Vector2.Zero, 0f, SpriteIDs.Player1_anim1_frame1)); }
public SearchItem(EnvironmentalItem content, string terms) { relevance = 0; item = content; foreach (string term in terms.Split(' ')) { relevance += (200 * Occurs(content.Title, term)); relevance += (20 * Occurs(content.Text, term)); } }
public SearchItem(Tip tip, string terms) { relevance = 0; item = tip; foreach (string term in terms.Split(' ')) { relevance += (200 * Occurs(tip.Title, term)); relevance += (20 * Occurs(tip.Body, term)); } }
public SearchItem(GlossaryItem gItem, string terms) { relevance = 0; item = gItem; foreach (string term in terms.Split(' ')) { relevance += (200 * Occurs(gItem.Title, term)); relevance += (20 * Occurs(gItem.Description, term)); } }
public void InactiveServer_CapturePoint_Is_Zero_And_Get_Charge_Then_CapturePoint_Will_Rise() { IInactiveNetworkController inactiveServer = new ServerObject(10, 0, 0, 40); Mock <IHumanPlayer> humanmock = new Mock <IHumanPlayer>(); var beforecaptuepoint = inactiveServer.CapturePoint; inactiveServer.OnCharge(humanmock.Object); Assert.That(inactiveServer.CapturePoint == beforecaptuepoint + 1); Assert.That(inactiveServer.Owner == humanmock.Object); }
public void If_Two_Server_With_Similar_Owner_Attack_Eachother_Then_One_Of_Them_Will_Call_Back_Their_Utp() { Mock <IHumanPlayer> humanmock = new Mock <IHumanPlayer>(); IServerNetworkController server1 = new ServerObject(humanmock.Object, 40, 0, 0, 40); IServerNetworkController server2 = new ServerObject(humanmock.Object, 40, 50, 50, 40); server1.Attack(server2); server2.Attack(server1); Assert.That(server1.Utps.First().Mode == UtpModes.Back); Assert.That(server2.Utps.First().Mode == UtpModes.Attack); }
public async Task NotifyUsersTest(ulong GuildId, [Remainder] string Message) { var embed = new EmbedBuilder(); var ns = ServerObject.GetSave(GuildId); embed.AddField($"Message From {Context.Guild.Name} Guild", $"This Message is notifying all logged users of the server: {ns.ServerName}\n\n" + $"{Message}"); embed.Color = Color.Green; await ReplyAsync("", false, embed.Build()); }
public void Level1_Server_After_20_Tick_Get_Life() { Mock <IHumanPlayer> humanmock = new Mock <IHumanPlayer>(); IServerNetworkController server = new ServerObject(humanmock.Object, 10, 0, 0, 40); for (int i = 0; i < 20; i++) { server.Tick(); } Assert.That(server.Life == 11); }
public void Level1_Server_With_14_Life_Get_New_Life_Then_It_Will_Level_Up() { Mock <IHumanPlayer> humanmock = new Mock <IHumanPlayer>(); IServerNetworkController server = new ServerObject(humanmock.Object, 14, 0, 0, 40); for (int i = 0; i < 20; i++) { server.Tick(); } Assert.That(server.Level == 2); }
public void If_Two_Enemy_Servers_Attack_Eachothe_Then_They_Will_Fight_In_Midle_Of_Battlefild() { Mock <IHumanPlayer> humanmock = new Mock <IHumanPlayer>(); Mock <ICpuPlayer> cpumock = new Mock <ICpuPlayer>(); IServerNetworkController server1 = new ServerObject(humanmock.Object, 40, 0, 0, 40); IServerNetworkController server2 = new ServerObject(cpumock.Object, 40, 50, 50, 40); server1.Attack(server2); server2.Attack(server1); Assert.That(server1.Utps.First().Mode == UtpModes.MoveToBattle); Assert.That(server2.Utps.First().Mode == UtpModes.MoveToBattle); }
public async void ViewServerDetails(ServerObject server) { var response = await Client._instance._httpClient.GetAsync($"{Constants.apiAddress}api/servers/{server.Id}/players"); var responseString = await response.Content.ReadAsStringAsync(); PlayerObject[] playerList = JsonConvert.DeserializeObject <PlayerObject[]>(responseString); _detailsMenuPlayerCreator.RefreshList(playerList); _detailsMenuServer.UpdateObject(0, server); _detailsMenu.SetActive(true); }
public static void SaveAsJson(this IEnumerable <ServerObject> servers, String file) { if (servers == null) { servers = new ServerObject[0]; } RootExportDto root = new RootExportDto { ServerObjects = servers.ToArray() }; File.WriteAllText(file, JsonConvert.SerializeObject(root)); }
private bool SaveOldSelectedServer() { try { if (_lastSelectedIndex == -1 || _lastSelectedIndex >= _modifiedConfiguration.configs.Count) { return(true); } var server = new ServerObject { v = "10" }; if (Uri.CheckHostName(server.add = IPTextBox.Text.Trim()) == UriHostNameType.Unknown) { MessageBox.Show(I18N.GetString("Invalid server address")); IPTextBox.Focus(); return(false); } var old = _modifiedConfiguration.configs[_lastSelectedIndex]; server.port = (int)ServerPortNum.Value; server.aid = (int)AlterIdNum.Value; server.ps = RemarksTextBox.Text; server.id = IDTextBox.Text; server.net = TPSelect.SelectedItem.ToString(); server.type = CTSelect.SelectedItem.ToString(); server.host = CDTextBox.Text; server.path = PathTextBox.Text; server.tls = SecuritySelect?.SelectedItem?.ToString() ?? ""; var localPort = (int)LocalPortNum.Value; var corePort = (int)CorePortNum.Value; Configuration.CheckServer(server.add); Configuration.CheckLocalPort(localPort); if (old != null) { server.group = old.group; } _modifiedConfiguration.configs[_lastSelectedIndex] = server; _modifiedConfiguration.localPort = localPort; _modifiedConfiguration.corePort = corePort; return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(false); }
// --------------------- SO --------------------------------- void AddSO(ServerObject so) { Debug.Log("prefub " + so.prefab); GameObject SObj = (GameObject)Instantiate(Resources.Load(so.prefab, typeof(GameObject)), so.position - zeroPoint, so.rotation); SObj.GetComponent <SOParametres> ().Init(so, this.gameObject); // Debug.Log (so.visibleName); nearestSOs.Add(so.id, SObj); Debug.Log("add SO id " + so.id); canvasobj.GetComponent <Indicators> ().AddIndicator_so(SObj); }
public void If_Wall_Is_Between_Two_Server_Then_Two_Server_Cannot_Connection_To_Eachother() { Mock <IHumanPlayer> humanmock = new Mock <IHumanPlayer>(); IActiveNetworkController active = new ServerObject(humanmock.Object, 100, 25, 25, 100); INetworkController target = new ServerObject(10, 125, 25, 100); IFireWall fireWall = new FireWall(75, 25); this.game.GameObjects.Add(active); this.game.GameObjects.Add(target); this.game.GameObjects.Add(fireWall); this.game.ConnectTwoServer(active, target); Assert.That(active.Utps.Count == 0); }
private ServerObject GetServerObject(ServerEventArgs e) { //TODO: Use response to do display error messages HttpStatusCode response = e.ServerResponse; ServerObject serverObject = e.ResponseObject; if (serverObject == null) { return(null); //TODO: Raise erorr or something } return(serverObject); }
static void Main(string[] args) { TcpChannel channel = new TcpChannel(); ChannelServices.RegisterChannel(channel, true); ServerObject serverObj = (ServerObject)Activator.GetObject( typeof(ServerObject), "tcp://localhost:8080/ServiceMessage"); Person person = serverObj.GetPersonInfo("张舒禹", "男", 25); Console.WriteLine($"{person.Name }{person.Sex}{person.Age}"); }
private void HandleLoginResponse(ServerObject response) { Connection.ServiceToken = response.Token; Connection.Expiration = response.Expiration; AuthenticationEventArgs args = new AuthenticationEventArgs() { Authorized = true, Expiration = response.Expiration, Token = response.Token }; OnLoiginRequestReturned(args); }
private static void Main() { try { _listenThread = Task.Factory.StartNew(ServerObject.Listen, TaskCreationOptions.LongRunning); _listenThread.Wait(); } catch (Exception ex) { ServerObject.Disconnect(); Console.WriteLine(ex.Message); } }
public static TcpListener tcpListener; // сервер для прослушивания public void Serv() { try { server = new ServerObject(); listenThread = new Thread(new ThreadStart(Listen)); listenThread.Start(); //старт потока } catch (Exception ex) { Disconnect(); Console.WriteLine(ex.Message); } }
/// <summary> /// Sends ServerObject to the server /// </summary> /// <param name="data">Data to send</param> public static async void SendToServer(ServerObject data) { try { // If there is no server connection, stablish if (senderServer == null || senderServer.Connected == false) { LoadingNotificator.LoadingInitialized(); try { senderServer = new TcpClient(serverAddress, SERVER_PORT); } catch (SocketException e) { if (reconnectingAttempts >= MAX_RECONNECTING_ATTEMPTS) { StatusBar.SetStatus($"{e.SocketErrorCode.ToString()}\nCannot stablish connection"); return; } StatusBar.SetStatus($"{e.SocketErrorCode.ToString()}\nTrying to reconnect in 10 seconds ({++reconnectingAttempts}/{MAX_RECONNECTING_ATTEMPTS} attempts)", 10000); await Task.Delay(10000); SendToServer(data); LoadingNotificator.LoadingFinished(); return; } _ = Task.Run(() => ListenServer(senderServer)); LoadingNotificator.LoadingFinished(); } lock (senderServer) // To not send too much data at same time { if (data.ServerFlag == ServerFlag.Error) { MessageBox.Show("Error sendind data to server"); } if (senderServer.Connected) { formatter.Serialize(senderServer.GetStream(), data); senderServer.GetStream().Flush(); } } } catch (Exception e) { MessageBox.Show(e.Message); } }
public void StartScan(Object sender, DoWorkEventArgs EventArgs) { BackgroundWorker worker = sender as BackgroundWorker; if (worker == null) { return; } bworker = worker; worker.ReportProgress(0); BackgroundObject background = (BackgroundObject)EventArgs.Argument; threshold = background.Treshold; Int32 duration = 100 / background.Servers.Count; for (Int32 index = 0; index < background.Servers.Count; index++) { // if single scan is selected, process entries that are marked to process. if (background.SingleScan && !background.Servers[index].CanProcess) { continue; } currentIndex = index; worker.ReportProgress(duration * index); srv = background.Servers[index]; globalErrors = globalWarnings = false; srv.Log.Clear(); srv.Log.Add($"**************************************************************************{_nl}"); srv.Log.Add($"Processing '{srv.ServerAddress}'{_nl}"); srv.Log.Add($"**************************************************************************{_nl}"); srv.Log.Add($"Scan started: {DateTime.Now:dd-MM-yyyy HH:mm:ss} {_nl}"); // prepare properties srv.ItemProgress = 0; worker.ReportProgress(0, new ReportObject { Action = "Clear", Index = index }); // execute main routine createRequest(); // calculate resulting status of the object getEffectiveStatus(); changeStatCounter(background.Counters); // release resources and close connections srv.Dispose(); srv.Log.Add("Finished!" + _nl); srv.ItemProgress = 100; srv.Log.Add("Scan ended: " + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss")); redirected = false; } worker.ReportProgress(100); }
static Thread listenThread; // потока для прослушивания static void Main(string[] args) { try { server = new ServerObject(); listenThread = new Thread(new ThreadStart(server.Listen)); listenThread.Start(); //старт потока } catch (Exception ex) { server.Disconnect(); Console.WriteLine(ex.Message); } }
static Thread listenThread; // потока для прослушивания static void Main(string[] args) { try { server = new ServerObject(); //инициализация сервера listenThread = new Thread(new ThreadStart(server.Listen)); //запуск в отдельном потоке прослушивателя соединения listenThread.Start(); //старт потока } catch (Exception ex) { server.Disconnect();//в случае проблем останавливаем соединения Console.WriteLine(ex.Message); } }
public void ConnectToServer(ServerObject server) { string[] ep = server.EndPoint.Split(':'); _ip = ep[0]; _port = int.Parse(ep[1]); _tcp = new TCP(); _udp = new UDP(); InitializeClientData(); _isConnected = true; _tcp.Connect(); }
private void createServer() { server = new ServerObject(IP, HOST); server.logger = Log; server.intiServer(); server.startServer(); server.respose = (s) => { string requstType = s.ReadString(); RequestsManager.ProcessRequst(requstType, s, this); }; }
private static void Main() { try { _server = new ServerObject(); _listenThread = new Thread(_server.Listen); _listenThread.Start(); } catch (Exception ex) { _server.Disconnect(); Console.WriteLine(ex.Message); } }
public Operation(Message message, ServerObject server) { this.message = message; this.server = server; switch (message.Operation) { case "request": SetOperation(new Request()); break; default: SetOperation(new Exit()); break; } }
/// <summary> /// HoldingServer初始化 /// </summary> public HoldingServer() { singleton = this; self = new ResHost(new IPEndPoint(Functions.SelfIP, Configuration.Port), Dns.GetHostName()); self.rGroup(Configuration.Groups); self.searchService = Functions.SearchService; lis = new Listener(Configuration.Port); lis.onAccept += new AcceptHandler(lis_onAccept); lis.onReceive += MessageDealer.UDPReceive; server = new ServerObject(); client = new ClientObject(); remoteAddress = Functions.RemoteIP; selfAddress = Functions.SelfIP; state = 0; }
public void AddBall(ServerObject ball) { Debug.Assert(Authority.Server == authority); if (Monitor.TryEnter(sharedDataLock, 5)) { balls.Add(ball); Debug.Log("New ball added to the World, ID: [" + ball.id + "]"); Monitor.Exit(sharedDataLock); } else { Thread.Sleep(5); AddBall(ball); } }
public ServerGame(ServerObject server) : base(server) { Players = new Dictionary<long, Player>(); }