private void OnLineReceived(string line)
        {
            string[] data = line.Split(' ');

            //begin with "@": treat as event message
            int eventId = 0;

            if (data.Length > 0 &&
                data[0].Length > 1 &&
                data[0][0] == '@' &&
                int.TryParse(data[0].Substring(1), out eventId)
                )
            {
                var args = new string[data.Length - 1];
                Array.Copy(data, 1, args, 0, args.Length);
                var eventMessage = new UArmEventMessage(eventId, args);
                ReceivedEvent?.Invoke(this, new UArmEventMessageEventArgs(eventMessage));

                return;
            }

            //begin with "$": treas as response
            int id = -1;

            if (data.Length > 1 &&
                data[0].Length > 1 &&
                data[0][0] == '$' &&
                int.TryParse(data[0].Substring(1), out id))
            {
                var args = new string[data.Length - 1];
                Array.Copy(data, 1, args, 0, args.Length);
                var response = new UArmResponse(id, args);

                //Terminate waiting process if pending exists
                if (_pendingCommandIds.ContainsKey(id))
                {
                    _responses[id] = response;
                    _pendingCommandIds[id].Cancel();
                }

                ReceivedResponse?.Invoke(this, new UArmResponseEventArgs(response));

                return;
            }


            //Unknown data
        }
 public static UArmErrorResponseException CreateExceptionFromResponse(UArmResponse res)
 {
     return(new UArmErrorResponseException($"ID:{res.Id}, Args=" + string.Join(", ", res.Args)));
 }
 public UArmResponseEventArgs(UArmResponse response)
 {
     Response = response;
 }