Пример #1
0
 public void setNewServer(IPacmanServer server, string serverUrl)
 {
     Console.WriteLine("NEW SERVER");
     this.server    = server;
     this.serverUrl = serverUrl;
     isServerDead   = false;
 }
        public FileMovementController(string file, IPacmanServer server, string serverUrl, int delta, int userId) : base(server, serverUrl, delta,
                                                                                                                         userId)
        {
            var lines = File.ReadAllLines(file);

            linesQueue = new Queue <string>(lines);
        }
 public MixedMovementController(string file, Form1 form, IPacmanServer server, string serverUrl, int delta,
                                int userId)
     : base(server, serverUrl, delta, userId)
 {
     fileController     = new FileMovementController(file, server, serverUrl, delta, userId);
     movementController = new MovementController(form, server, serverUrl, delta, userId);
     currentController  = fileController;
 }
Пример #4
0
 protected AbstractMovementController(IPacmanServer server, string serverUrl, int delta, int userId)
 {
     this.userId    = userId;
     this.server    = server;
     this.serverUrl = serverUrl;
     timer          = new Timer(delta)
     {
         AutoReset = true
     };
     timer.Elapsed += (sender, args) => NotifyServer();
     isServerDead   = true;
 }
Пример #5
0
 private void addClientToServer(IPacmanServer server, int attempted)
 {
     try
     {
         server.addClient(this);
     }
     catch (Exception)
     {
         if (attempted <= KeyConfiguration.MAX_ATTEMPTS)
         {
             Thread.Sleep(ConnectionLibrary.INTERVAL_RESEND);
             addClientToServer(server, attempted++);
         }
     }
 }
Пример #6
0
 private void sendKeyToServer(IPacmanServer server, KeyConfiguration.KEYS key, String clientName, int attempt)
 {
     try
     {
         server.sendKey(keyToSend, pacmanName);
     }
     catch (Exception)
     {
         if (attempt <= KeyConfiguration.MAX_ATTEMPTS)
         {
             Thread.Sleep(ConnectionLibrary.INTERVAL_RESEND);
             sendKeyToServer(server, key, clientName, attempt++);
         }
     }
 }
Пример #7
0
        public void Start()
        {
            new Thread(() => Application.Run(form)).Start();

            RegisterTCPChannel();
            RegisterClientChannel();
            server = GetServerConnection();

            var clientInfo = new ClientInfo($"tcp://{clientIP}:{clientPort}");

            ClientPuppet.Instance.DoDelay(serverURL);
            var gameProps = server.RegisterClient(clientInfo);

            InitializeControllers(gameProps);

            InitializePuppet();
        }
Пример #8
0
 public MovementController(Form1 form, IPacmanServer server, string serverUrl, int delta, int userId) :
     base(server, serverUrl, delta, userId)
 {
     this.form = form;
 }