Esempio n. 1
0
 private void RegisterEventHandlers(IHubProxy proxy, IStockTickerHubClient client)
 {
     proxy.On <string>("SetMarketState", (x) => Device.BeginInvokeOnMainThread(() => client.SetMarketState(x)));
     proxy.On <Stock>("UpdateStockPrice", (x) => Device.BeginInvokeOnMainThread(() => client.UpdateStockPrice(x)));
     proxy.On <Stock>("SetStock", (x) => Device.BeginInvokeOnMainThread(() => client.SetStock(x)));
     proxy.On <OrderRecord>("UpdateOrderBuy", (x) => Device.BeginInvokeOnMainThread(() => client.UpdateOrderBuy(x)));
     proxy.On <OrderRecord>("UpdateOrderSell", (x) => Device.BeginInvokeOnMainThread(() => client.UpdateOrderSell(x)));
     proxy.On <Asset>("UpdateAsset", (x) => Device.BeginInvokeOnMainThread(() => client.UpdateAsset(x)));
     proxy.On <double>("SetInitialAsset", (x) => Device.BeginInvokeOnMainThread(() => client.SetInitialAsset(x)));
 }
Esempio n. 2
0
        public async Task Init(string serverUrl, IStockTickerHubClient client)
        {
            // Connect to the server
            hubConnection = new HubConnection(serverUrl);

            // Create a proxy to the 'stockTicker' SignalR Hub
            stockTickerProxy = hubConnection.CreateHubProxy("stockTicker");
            // Register event handlers
            RegisterEventHandlers(stockTickerProxy, client);

            // Start the connection
            await hubConnection.Start();
        }
Esempio n. 3
0
        public async Task Init(string serverUrl, IStockTickerHubClient client)
        {
            // Connect to the server
            hubConnection = new HubConnection(serverUrl);

            //hubConnection.Error +=
            //    ex => {
            //        Console.WriteLine("SignalR error: {0}\r\n", ex.Message);
            //    };

            // Create a proxy to the 'stockTicker' SignalR Hub
            stockTickerProxy = hubConnection.CreateHubProxy("stockTicker");
            // Register event handlers
            RegisterEventHandlers(stockTickerProxy, client);

            // Start the connection
            await hubConnection.Start();
        }