private async void btnStopSensor_Click(object sender, RoutedEventArgs e) { //stop sensor await _dataProvider.StopSensorMeasureAsync(); //Socket.IO if (_socketIOClient != null) { _socketIOClient.Close(); _socketIOClient.Dispose(); _socketIOClient = null; } }
public async void StartConnection() { this.client = new SocketIOClient.WinRT.Client(this.address); this.client.Error += OnError; this.client.Message += OnMessage; this.client.On("connect", (fn) => { System.Diagnostics.Debug.WriteLine("Connection Successful"); this.client.Emit("ClientConnect", new { this.username }); RaiseConnected(new EventArgs()); }); await this.client.ConnectAsync(); }
private async void btnStartSensor_Click(object sender, RoutedEventArgs e) { var endpoint = @"http://*****:*****@"http://xxx.azurewebsites.net"; var extension_socketio = @"/socket.io"; var endpoint_full_url = endpoint + extension_socketio; _socketIOClient = new Client(endpoint_full_url); _socketIOClient.Opened += SocketOpened; _socketIOClient.Message += SocketMessage; _socketIOClient.SocketConnectionClosed += SocketConnectionClosed; _socketIOClient.Error += SocketError; #region async lambda handler _socketIOClient.On("connect", async(fn) => { if (_socketIOClient.IsConnected) { // Implémentation des namespaces à revoir dans Socketio4WinRT //IEndPointClient ns = await _socketIOClient.ConnectEndpointAsync(socketio_namespace); try { CoreDispatcher dispatcher = this.Dispatcher; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { TextStatusSocketio.Text = "Connexion Socket.io établie"; }); await _dataProvider.InitializeSensorAsync(); } catch (Exception x) { Debug.WriteLine(x.Message); throw; } } }); #endregion await _socketIOClient.ConnectAsync(); }