Esempio n. 1
0
        public async void StartListening()
        {
            _connection = new HubConnectionBuilder()
                          .WithUrl("https://sandgatethapi.azurewebsites.net/api/")
                          .Build();

            _connection.Closed += async(error) =>
            {
                await Task.Delay(new Random().Next(0, 5) * 1000);

                await _connection.StartAsync();
            };

            _connection.On <ClientMessage>("ClientMessage", (cm) =>
            {
                if (cm.Direction == "SPA2Station" && cm.StationId == _hubDeviceID)
                {
                    Debug.WriteLine(cm.Command);

                    ClientCommandEventArgs args = new ClientCommandEventArgs();
                    GameCommand gc   = new GameCommand(cm.Command, cm.Parameters);
                    args.gameCommand = gc;
                    OnCommandReceived(args);
                }
            });


            try
            {
                await _connection.StartAsync();

                //   messagesList.Items.Add("Connection started");
                //   connectButton.IsEnabled = false;
                //    sendButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                string s = ex.Message;
                //    messagesList.Items.Add(ex.Message);
            }
        }
Esempio n. 2
0
 public CommunicationObject(GameCommand command, string data)
 {
     this.command = command;
     this.data    = data;
 }
Esempio n. 3
0
 // Called by the manager when a command comes in from client
 public virtual void ProcessGameCommand(GameCommand gc)
 {
 }