Example #1
0
        //Start the HubConnection Client
        public async void startClient()
        {
            //Create connection
            Connection = new HubConnectionBuilder()
                         .WithUrl("http://*****:*****@"State: " + playerAmt + @" Player(s) Connected. " + plrsReady + @" Ready";
            });

            //On Run Signal
            Connection.On("Run", () =>
            {
                int i     = Guid.NewGuid().GetHashCode();
                ownRandom = new Random(i);
                Debug.WriteLine(ownRandom.GetHashCode());
                Connection.InvokeAsync("TradeRandom", i);
            });

            //On Trade Signal
            Connection.On("TradeRandom", (int random) =>
            {
                otherRandom = new Random(random);
                Debug.WriteLine(otherRandom.GetHashCode());
                onTetrisRun(ownRandom, otherRandom);
            });

            //On position signal
            Connection.On <char>("KeyPress", (key) =>
            {
                currentEngine.otherPlayerKeyPress(key);
            });

            //On grid signal
            Connection.On <string>("SendSerializedGrid", grid =>
            {
                currentEngine.otherPlayerSetGrid(grid);
            });

            //Attempt start
            await Connection.StartAsync();
        }