Esempio n. 1
0
        public void StartServer(string pid, string server_url, int msec_per_round, int num_players)
        {
            Console.WriteLine("Server started on " + server_url);
            //string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"\Server\bin\Debug\Server.exe");

            string path = "..\\..\\..\\Server\\bin\\Debug\\Server.exe";

            Console.WriteLine(path);

            //"Usage: Server.exe server_uri number_of_players round_time(ms)"
            string  args = server_url + " " + num_players + " " + msec_per_round;
            Process p    = StartProgram(path, args);

            pid_process_dict.Add(pid, p);

            //IRemoteEntity server = Activator.GetObject(typeof(IRemoteGame), server_url) as IRemoteEntity;
            IRemoteGame server = Activator.GetObject(typeof(IRemoteGame), server_url) as IRemoteGame;

            pid_instance_dict.Add(pid, server);
        }
Esempio n. 2
0
        public Chat(IRemoteGame game, OGPPlayer sender, List <OGPPlayer> players, GameParameters parameters)
        {
            var           participants_uris = new HashSet <string>();
            List <string> procNames         = new List <string>();

            this.game         = game ?? throw new ArgumentNullException(nameof(game));
            this.self         = sender ?? throw new ArgumentNullException(nameof(sender));
            this.participants = players ?? throw new ArgumentNullException(nameof(players));
            this.parameters   = parameters ?? throw new ArgumentNullException(nameof(parameters));

            foreach (var player in players)
            {
                procNames.Add(player.ChatProcessName);
                participants_uris.Add(player.ChatUri);
            }

            this.localClock = new VectorClock(procNames);
            this.multicast  = new RemoteReliableMulticast(participants_uris, sender.ChatUri);
            this.multicast.MessageDeliveredEvent += multicastDeliverMessageEventHandler;
        }