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); } }
public CommunicationObject(GameCommand command, string data) { this.command = command; this.data = data; }
// Called by the manager when a command comes in from client public virtual void ProcessGameCommand(GameCommand gc) { }