public void ConnectTo(BluetoothPeripheralParams newPeripheralParams) { if (_peripheralParams.HasValue && newPeripheralParams.Equals(_peripheralParams.Value)) { logger.Warning("Already connected to this peripheral: " + newPeripheralParams); return; } #if UNITY_EDITOR _state = States.None; _connected = true; if (OnConnect != null) { OnConnect(); } return; #endif ResetState(() => { _peripheralParams = newPeripheralParams; BluetoothLEHardwareInterface.Initialize(true, false, () => { logger.DebugLog("Initialized bluetooth hardware interface."); SetState(States.Scan, 0.1f); }, (error) => { logger.Error("Error initializing bluetooth hardware interface: " + error); }); }); }
public void UpdatePosition(EntityId id, Coordinates coord) { if (Positions.HasAuthority(id)) { if (Positions.TryGetValue(id, out var position)) { var update = new Position.Update() { coords = coord }; Connection.SendComponentUpdate(id, update); update.ApplyTo(position); } else { Logger.Error("Unable to get position for [" + id.Id + "]"); } } else { Logger.Error("Worker does not have authority over position of [" + id.Id + "]"); } }
private T Recompute() { if (_names.All(name => _values.ContainsKey(name))) { var valuesArray = _names.Select(name => this._values[name]).ToArray(); try { return((T)_parser.DynamicInvoke(valuesArray)); } catch (Exception e) { _logger.Error("Exception while parsing flag", e); return(_defaultValue); } } return(_defaultValue); }
private static void RunEventLoop() { var exampleBehaviour = new ExampleBehaviour(env); metricsGapTimer.Start(); // run loop while (isConnected) { FetchAndProcessOps(env.Connection, dispatcher, tickTimeMillis); try { workTimer.Start(); exampleBehaviour.Tick(tickTimeMillis); } catch (Exception e) { logger.Error("Caught exception during Tick()", e); } finally { workTimer.Stop(); Thread.Sleep((int)tickTimeMillis); } } }