public void ReceiveValue(float val, string time, bool isElbow) { Log("Received val: " + val + " at: " + time + " isElbow: " + isElbow); if (isElbow) { elbowValue = val.ToString(); OnElbowValue?.Invoke(new MqttEntry("elbow", val, time)); } else { wristValue = val.ToString(); OnWristValue?.Invoke(new MqttEntry("wrist", val, time)); } }
public override void MessageReceived(string message) { base.MessageReceived(message); var data = message.Split(','); var unitytime = DateTime.Now.ToString("HH:mm:ss.ffffff"); if (data.Length == 3) { if (float.TryParse(data[0], NumberStyles.Any, CultureInfo.InvariantCulture, out _elbowValue)) { OnElbowValue?.Invoke(new UdpEntry(ELBOW_ID, _elbowValue, data[2], unitytime)); } if (float.TryParse(data[1], NumberStyles.Any, CultureInfo.InvariantCulture, out _wristValue)) { OnWristValue?.Invoke(new UdpEntry(WRIST_ID, _wristValue, data[2], unitytime)); } } }
void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) { //Debug.Log("Received = " + Encoding.UTF8.GetString(e.Message) + " on topic " + e.Topic); if (e.Topic == _elbowTopic) { // Do anything with the value elbowValue = Encoding.UTF8.GetString(e.Message); //Pass on the value to all event subscribers OnElbowValue?.Invoke(MessageToEntry(_elbowTopic, elbowValue)); } else if (e.Topic == _wristTopic) { // Do anything with the value wristValue = Encoding.UTF8.GetString(e.Message); //Pass on the value to all event subscribers OnWristValue?.Invoke(MessageToEntry(_wristTopic, wristValue)); } }