public ClientGameController(ServerCommunicator communicator, Team team) { this.communicator = communicator ?? throw new ArgumentNullException(nameof(communicator)); HomeTeam = team ?? throw new ArgumentNullException(nameof(team)); this.communicator.DataReceived += Communicator_DataReceived; this.communicator.StartCommunication(); }
public void Setup() { ConfigurationMock = new Mock <IConfiguration>(); ChatClient = new ChatClient(ConfigurationMock.Object); Server = new ServerCommunicator("localhost", 22000); CancellationTokenSource = new CancellationTokenSource(); }
public MainForm() { InitializeComponent(); ServerCommunicator.Connect(); // Sending a message: ServerCommunicator.SendMessage("Hello server!"); }
public User() { this.InitializeComponent(); serverChannel = new ServerCommunicator(); //domainListBox.ItemContainerGenerator.StatusChanged += new EventHandler(ItemContainerGenerator_StatusChanged); // Insert code required on object creation below this point. }
internal void StartAll() { ServerCommunicator.StartService(); ClientCommunicator.StartService(); LoginService.StartService(); QLKHDataService.StartService(); }
private async void Login_Execute() { // Denne metode skal der hentes bruger data fra serveren // Den bruger data der hentes, skal sendes videre til næste view. Som er HostMenu. // Brugeren hente ned og bruger data tilføres et bruger objekt. IServerDataHandler handler = new ServerDataHandler(); IServerCommunicator Com = new ServerCommunicator(handler); if (await Com.SendDataReturnIsValid(Host, DataType.Host)) { IFromJSONParser Parser = new FromJsonParser(); var ServerHost = await Parser.DeserializedData <ReturnHostModel>(handler.LatestMessage); var rootPage = Navigation.NavigationStack.FirstOrDefault(); if (rootPage != null) { var page = (ServerHost.Events != null) ? new HostMainMenu(ServerHost, ServerHost.Events.ToList()) : new HostMainMenu(ServerHost); _memoryManager.SaveCookie(handler.LatestReceivedCookies, ServerHost.Name); Navigation.InsertPageBefore(page, Navigation.NavigationStack.First()); await Navigation.PopToRootAsync(); } } }
internal void CloseAll() { ServerCommunicator.CloseService(); ClientCommunicator.CloseService(); LoginService.CloseService(); QLKHDataService.CloseService(); }
/// <summary> /// When the user clicks the login button we use the data entered by the user to try to login /// Checks are performed to assure that the user input is correct /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonLogin_Click(object sender, RoutedEventArgs e) { /* get the user name */ this.username = textBoxUserName.Text; /* if there is no input */ if (this.username.Length == 0) { /* show an error dialog when the user does not enter the correct data */ MessageBox.Show("Please enter a valid user name!", "Invalid user name", MessageBoxButton.OK, MessageBoxImage.Exclamation); /* focus the text box */ this.textBoxUserName.Focus(); return; } /* a default port number */ int portNumber = 12346; /* check if the port is correct */ if (textBoxPortNumber.Text.Length > 0) { try { /* parse it to int */ portNumber = Int32.Parse(textBoxPortNumber.Text); } catch (Exception ex) { MessageBox.Show("Please enter a valid port number!", "Invalid port number", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } } /* create a callback sink for the client */ messagesCallback = new CallbackSink(); /* we attach the delagate so that we can get messages from the server through it */ messagesCallback.fromServerToUser += new delegateCommunication(delegateFromServerToUser); try { /* because of the delegate we need a channel from the server to the client */ channel = new TcpChannel(portNumber); /* register it */ ChannelServices.RegisterChannel(channel, false); /* create the reference */ serverReference = (ServerCommunicator)Activator.GetObject(typeof(ServerCommunicator), "tcp://localhost:12345/ServerAccess"); } catch (Exception exc) { Debug.WriteLine(exc); } /* now we can use the reference to login */ serverReference.loginUserAndAdd(this.textBoxUserName.Text, new delegateCommunication(messagesCallback.HandleToClient)); /* prepare de GUI */ initializeForChat(); }
private void ProcessClientPacket(Packet packet, ServerCommunicator communicator, TeamData teamData1, TeamData teamData2) { var messageType = (MessageType)packet.Header.MessageType; var command = (CommandType)packet.Header.Command; // If the first three initialization messages have not been processed yet if (teamData1.MessageRead < 2) { switch (teamData1.MessageRead) { case 0 when(messageType == MessageType.Team) && (command == CommandType.Set): if (ProcessTeamMessage(packet, teamData1)) { return; } break; case 0: Console.WriteLine("Invalid packet."); return; case 1 when(messageType == MessageType.Pitch) && (command == CommandType.Get): ProcessPitchMessage(communicator, teamData1); break; case 1: Console.WriteLine("Invalid packet."); return; } } else { switch (messageType) { case MessageType.PositionCollection when command == CommandType.ContinuousSet: ProcessPositionCollectionMessage(packet, communicator); break; case MessageType.BallPosition when command == CommandType.ContinuousSet: ProcessBallMessage(packet); break; default: Console.WriteLine("Invalid/unknown packet."); break; } } teamData1.MessageRead++; }
/// <summary> /// This method will call the notification for the users /// </summary> /// <param name="Info"></param> private void userToHost(Communication Info) { /* log the communication */ Log.debug("From " + Info.UserName + " : " + Info.Content + Environment.NewLine); /* send the message to all concerned users */ ServerCommunicator.notifyUsersOfCommunication(Info.UserName, Info.Content, Info.Type); }
private async Task ScanServerFolders() { var ep = Common.Extensions.ParseEndpoint(_serverUrl); var comm = new ServerCommunicator(); var folders = await comm.GetFolders(FileSyncApp.Instance.Config.ClientId, ep.Address, ep.Port); _folders.SetList(folders); }
private async Task <bool> DoPing(ServerListDataItem server) { var comm = new ServerCommunicator(); var prevState = server.State; server.State = await comm.PingServer(server); return(server.State != prevState); }
/// <summary> /// Initializes a new instance of the <see cref="ZeusOperations"/> class. /// </summary> public ZeusOperations() { if (Communicator == null) { Communicator = new ServerCommunicator() { Endpoint = "server.zeus.shanecraven.com", Port = 9000 }; } }
/// <summary> /// Gets a list of all the ServiceObjective for a server /// </summary> /// <param name="resourceGroupName">The name of the resource group</param> /// <param name="serverName">The name of the server</param> /// <returns>A list of all the ServiceObjectives</returns> public List <AzureSqlServerServiceObjectiveModel> ListServiceObjectives(string resourceGroupName, string serverName) { var server = ServerCommunicator.Get(resourceGroupName, serverName); var capabilities = CapabilitiesCommunicator.Get(server.Location); return(( from serverVersion in FilterByName(capabilities.SupportedServerVersions, server.Version) from edition in serverVersion.SupportedEditions from serviceObjective in edition.SupportedServiceLevelObjectives select CreateServiceObjectiveModelFromResponse(edition, serviceObjective, resourceGroupName, serverName)).ToList()); }
public void Setup() { com = new ServerCommunicator(); Eventmodel = new EventModel(); Eventmodel.Pin = "1234"; Eventmodel.Description = "Description"; Eventmodel.EndDate = DateTime.MaxValue; Eventmodel.StartDate = DateTime.MinValue; Eventmodel.Location = "På skolen"; Eventmodel.Name = "Navn på event"; EventSeeImages = new EventSeeImagesViewModel(Eventmodel); }
private void ProcessPitchMessage(ServerCommunicator communicator, TeamData teamData1) { Stream data = DataSerializer.CreateSerializedData(pitch); PacketHeader header = PacketHeaderCreator.Create(CommandType.Set, MessageType.Pitch, data.Length); Console.WriteLine("Pitch getter message has been processed."); communicator.SendDataAsPacket(new Packet(header, data)); Console.WriteLine("Pitch setter message has been sent."); Console.WriteLine("Team is ready."); teamData1.TeamReady = true; }
private void ProcessPositionCollectionMessage(Packet packet, ServerCommunicator communicator) { var collection = DataSerializer.ReadSerializedData <PositionCollection>(packet.Data); if (collection is null) { Console.WriteLine("The Position Collection message is invalid."); return; } // Store the Position Collection game.ProcessPositionCollection(collection, communicator == homeTeamCommunicator); Console.WriteLine("Position Collection message has been processed."); }
private void SendOverallMatchData(ServerCommunicator communicator, CommandType commandType) { semaphore.Wait(); Stream data = DataSerializer.CreateSerializedData(OverallMatchStandingCreator.Create(game, matchTimer, communicator != homeTeamCommunicator)); PositionCollection test = DataSerializer.ReadSerializedData <OverallMatchStanding>(data).PositionCollection; PacketHeader header = PacketHeaderCreator.Create(commandType, MessageType.OverallMatchData, data.Length); communicator.SendDataAsPacket(new Packet(header, data)); semaphore.Release(); }
public MainWindow() { InitializeComponent(); endPoint = new IPEndPoint(IPAddress.Loopback, 55555); client = new TcpClient { ReceiveBufferSize = Convert.ToInt32(Math.Pow(2, 16)) }; client.Connect(endPoint); communicator = new ServerCommunicator(client); controller = new ClientGameController(communicator, team); SubscribeForEvents(); }
public DisplayData() { InitializeComponent(); var webResponse = new ServerCommunicator().GetRequest("/activities"); var serializer = new DataContractJsonSerializer(new List <Activity>().GetType()); var deserializedActivity = serializer.ReadObject(webResponse.GetResponseStream()) as List <Activity>; webResponse.Close(); foreach (var a in deserializedActivity) { Console.WriteLine(a.name); } this.lbActivities.Items.AddRange(deserializedActivity.ToArray()); }
private async void AddServerBtnOnClick(object sender, EventArgs e) { if (!IPAddress.TryParse(_addressTxtView.Text, out var addr)) { Toast.MakeText(this, "Address invalid", ToastLength.Short).Show(); return; } if (!int.TryParse(_portTxtView.Text, out var port)) { Toast.MakeText(this, "Port invalid", ToastLength.Short).Show(); return; } var comm = new ServerCommunicator(); var id = await comm.GetServerId(addr, port); if (!id.HasValue) { Toast.MakeText(this, "Unable to contact server", ToastLength.Short).Show(); return; } if (FileSyncApp.Instance.Config.Servers.Any(x => x.Id == id.Value)) { Toast.MakeText(this, "Server already added", ToastLength.Short).Show(); return; } var res = await comm.RegisterClient(FileSyncApp.Instance.Config.ClientId, addr, port); if (!res) { Toast.MakeText(this, "Unable to register client", ToastLength.Short).Show(); return; } FileSyncApp.Instance.Config.AddServer(id.Value, new IPEndPoint(addr, port).ToString()); FileSyncApp.Instance.Config.Store(); Toast.MakeText(this, "Server added successfully", ToastLength.Short).Show(); Finish(); }
public static ServerCommunicator instance = null; //Static instance of Globals which allows it to be accessed by any other script. //Awake is always called before any Start functions void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a Globals. Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); }
public void Setup() { uut = new ServerCommunicator(); }
private void CheckPartnerResourceGroupValid(string partnerResourceGroupName) { // checking if the resource group is valid as a partner resource group ServerCommunicator.ListByResourceGroup(partnerResourceGroupName); }
public void SetAwayTeamCommunicator(ServerCommunicator awayTeamCommunicator) { this.awayTeamCommunicator = awayTeamCommunicator ?? throw new ArgumentNullException(nameof(awayTeamCommunicator)); this.awayTeamCommunicator.DataReceived += AwayTeamCommunicator_DataReceived; this.awayTeamCommunicator.StartCommunication(); }
private void CheckPartnerResourceGroupValid(string partnerResourceGroupName) { // checking if the resource group is valid as a partner resource group ServerCommunicator.List(partnerResourceGroupName, Util.GenerateTracingId()); }
public YZ_Home() { InitializeComponent(); serverChannel = new ServerCommunicator(); }
public DesktopPools() { InitializeComponent(); serverChannel = new ServerCommunicator(); poolListBox.ItemContainerGenerator.StatusChanged += new EventHandler(ItemContainerGenerator_StatusChanged); }
public void StartServer() { server = new ServerCommunicator(gameUrl); }
static void Main(string[] args) { ServerCommunicator.SkipServerLaunch = false; bool Parallelize = true; // Failed to find any possible distant turning point, possibly blocked by other agents. // string levelPath = "MANOAsArk.lvl"; // Failed to find the agent. // string levelPath = "MAOneOneTwo.lvl"; // Index was outside the bounds of the array. // string levelPath = "SAGroupName.lvl"; // sub problem depth limit reached. // string levelPath = "MAGroupName.lvl"; // reee // string levelPath = "SARegExAZ.lvl"; // string levelPath = "MABob.lvl"; // Pulling to faraway turn-point not yet implemented. //string levelPath = "MASoulman.lvl"; //string levelPath = "SAOneOneTwo.lvl"; // Found no path from entity to goal. // string levelPath = "SAAIMAS.lvl"; // string levelPath = "SAPOPstars.lvl"; // Can't move into agent // string levelPath = "MAgroup.lvl"; // string levelPath = "MANulPoint.lvl"; //Not enough free space is available string levelPath = "MABob.lvl"; //string levelPath = "SAWallZ.lvl"; //string levelPath = "SAgTHIRTEEN.lvl"; //string levelPath = "SANulPoint.lvl"; //string levelPath = "SATheBTeam.lvl"; //string levelPath = "MAgTHIRTEEN.lvl"; //string levelPath = "MAMKM.lvl"; //string levelPath = "MASubpoena.lvl"; //string levelPath = "MAMASAI.lvl"; #region Mein Levels //string levelPath = "SAVisualKei.lvl"; //string levelPath = "MAVisualKei.lvl"; #endregion #region Optimize these //string levelPath = "SAanagram.lvl"; //string levelPath = "SAtesuto.lvl"; #endregion #region Bugfix //string levelPath = "MACorridor.lvl"; //string levelPath = "SAsimple2.lvl"; //string levelPath = "SADangerbot.lvl"; #endregion //Not enough free space //string levelPath = "SAGroupOne.lvl"; string convertedLevelPath = "temp.lvl"; ServerCommunicator serverCom = new ServerCommunicator(); if (args.Length == 0 && !ServerCommunicator.SkipServerLaunch) { levelPath = GetLevelPath(levelPath); ConvertFilesToCorrectFormat(levelPath, convertedLevelPath); serverCom.StartServer(convertedLevelPath); } else { ServerCommunicator.GiveGroupNameToServer(); Level level; if (ServerCommunicator.SkipServerLaunch) { levelPath = GetLevelPath(levelPath); ConvertFilesToCorrectFormat(levelPath, convertedLevelPath); level = Level.ReadLevel(File.ReadAllLines(convertedLevelPath)); } else { level = ServerCommunicator.GetLevelFromServer(); } var highLevelCommands = ProblemSolver.SolveLevel(level, TimeSpan.FromHours(1), false); var lowLevelCommands = serverCom.NonAsyncSolve(level, highLevelCommands); if (!Parallelize) { serverCom.SendCommandsSequentially(lowLevelCommands, level); } else { var finalCommands = CommandParallelizer.Parallelize(lowLevelCommands, level); serverCom.SendCommands(finalCommands); } Console.Read(); return; } }