public bool OnUpdateAccelerometer(Accelerometer.Accelerometer accelerometer) { try { NetWorkHelper.Send(string.Format("^{0}|{1}|{2}|{3}|{4}|{5}|{6}$", accelerometer.Rotation, progressBrake, progressRun, _button01Clicked, _button02Clicked, _button03Clicked, _button04Clicked)); _button01Clicked = 0; _button02Clicked = 0; _button03Clicked = 0; _button04Clicked = 0; } catch (SocketException ex) { //UIHelper.ShowMessage("Sending error:" + ex.Message, this); NetWorkHelper.Reconnect(); } catch (Java.Net.SocketException ex) { //UIHelper.ShowMessage("Sending error:" + ex.Message, this); NetWorkHelper.Reconnect(); } catch (Exception ex) { UIHelper.ShowMessage("Sending error:" + ex.Message, this); } return(NetWorkHelper.IsConnected); }
public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId) { netWorkHelper = new NetWorkHelper(); var ip = intent.GetStringExtra("ip"); try { NetWorkHelper.Connect(ip); } catch (Exception ex) { Log.Debug("NetworkService", "Connection error:" + ex.Message); } if (NetWorkHelper.IsConnected) { NetWorkHelper.Send("I connected with you!"); } // Return the correct StartCommandResult for the type of service you are building return(StartCommandResult.NotSticky); }
public bool OnUpdateAccelerometer(Accelerometer.Accelerometer accelerometer) { try { NetWorkHelper.Send(string.Format("^{0}|{1}|{2}|{3}$", accelerometer.Rotation, progressBrake, progressRun, GetButtonStatecPacked())); ClearButtonStates(); } catch (SocketException ex) { UIHelper.ShowMessage("Sending error:" + ex.Message, this); //NetWorkHelper.Reconnect(); } catch (Java.Net.SocketException ex) { UIHelper.ShowMessage("Sending error:" + ex.Message, this); //NetWorkHelper.Reconnect(); } catch (Exception ex) { UIHelper.ShowMessage("Sending error:" + ex.Message, this); } return(NetWorkHelper.IsConnected); }