public void SendCommand(XPlaneCommand command)
        {
            var dg = new XPDatagram();

            dg.Add("CMND");
            dg.Add(command.Command);

            client.Send(dg.Get(), dg.Len);
        }
Beispiel #2
0
        /// <summary>
        /// Sends a command
        /// </summary>
        /// <param name="command">Command to send</param>
        public void SendCommand(XPlaneCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var dg = new XPDatagram("CMND", command.Command);

            client.Send(dg.Bytes, dg.Bytes.Length);
        }
        /// <summary>
        /// Sends a command continously. Use return parameter to cancel the send cycle
        /// </summary>
        /// <param name="command">Command to send</param>
        /// <returns>Token to cancel the executing</returns>
        public CancellationTokenSource StartCommand(XPlaneCommand command)
        {
            var tokenSource = new CancellationTokenSource();

            Task.Run(() =>
            {
                while (!tokenSource.IsCancellationRequested)
                {
                    SendCommand(command);
                }
            }, tokenSource.Token);

            return(tokenSource);
        }
        /// <summary>
        /// Sends a command
        /// </summary>
        /// <param name="command">Command to send</param>
        public void SendCommand(XPlaneCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var dg = new XPDatagram();

            dg.Add("CMND");
            dg.Add(command.Command);

            client.Send(dg.Get(), dg.Len);
        }