Exemplo n.º 1
0
        private void OnLpdCodeReceived(DeviceMessage deviceMessage)
        {
            var message    = Encoding.UTF8.GetString(deviceMessage.Payload);
            var regexMatch = Regex.Match(message, "([0-9]+),([0-9]+),([0-9]+)");

            var value    = uint.Parse(regexMatch.Groups[1].Value);
            var length   = int.Parse(regexMatch.Groups[2].Value);
            var protocol = int.Parse(regexMatch.Groups[3].Value);

            CodeReceived?.Invoke(this, new Ldp433MhzCodeReceivedEventArgs(new Lpd433MhzCode(value, length, protocol, 0)));
        }
Exemplo n.º 2
0
        private void OnLpdCodeReceived(DeviceMessage deviceMessage)
        {
            var json     = JObject.Parse(Encoding.UTF8.GetString(deviceMessage.Payload));
            var value    = json["value"].Value <uint>();
            var length   = json["length"].Value <int>();
            var protocol = json["protocol"].Value <int>();

            CodeReceived?.Invoke(this, new Ldp433MhzCodeReceivedEventArgs(new Lpd433MhzCode {
                Value = value, Length = length, Protocol = protocol, Repeats = 0
            }));
        }
Exemplo n.º 3
0
        internal ReplaySubject <IKernelEvent> ReceiveCode(string token,
                                                          string code,
                                                          string language = "csharp")
        {
            var stream = new ReplaySubject <IKernelEvent>();

            CodeReceived?.Invoke(this, new CodeReceivedEventArgs
            {
                CommandToken      = token,
                KernelEventStream = stream
            });

            if (CodeReceived == null)
            {
                stream.OnError(new InvalidOperationException("No code handler registered."));
            }

            return(stream);
        }
 private void OnCodeReceived(CodeReceivedEventArgs e)
 {
     CodeReceived?.Invoke(this, e);
 }