/// <summary> /// Configures the unique UDP connection. /// </summary> /// <param name="connectionInfo">The connection information.</param> /// <param name="reporter">The reporter.</param> /// <param name="timeout">The timeout in milliseconds.</param> /// <param name="retryLimit">The retry limit.</param> /// <returns>UdpConnectionInfo.</returns> /// <exception cref="System.Exception">Device send IP address and/or port could not be configured for unique connection.</exception> /// <autogeneratedoc /> /// <remarks> /// The device may not respond for up to 5 seconds. The total retry period must therefore be greater than 5 seconds. /// </remarks> public static UdpConnectionInfo ConfigureUniqueUdpConnection(UdpConnectionInfo connectionInfo, IReporter reporter = null, int timeout = 500, int retryLimit = 20) { UdpConnectionInfo uniqueConnectionInfo = UdpConnectionInfo.CreateUniqueConnectionInfo(connectionInfo); Connection uniqueConnection = new Connection(uniqueConnectionInfo); try { if (reporter != null) { uniqueConnection.Error += reporter.OnError; uniqueConnection.Exception += reporter.OnException; uniqueConnection.Info += reporter.OnInfo; uniqueConnection.Message += reporter.OnMessage; } // connect using the correct receive Port uniqueConnection.Connect(); uniqueConnection.Settings.WifiSendIPAddress.Value = uniqueConnectionInfo.AdapterIPAddress; uniqueConnection.Settings.WifiSendPort.Value = (ushort)uniqueConnectionInfo.ReceivePort; ISettingItem[] settingsToBeWritten = new ISettingItem[] { uniqueConnection.Settings.WifiSendIPAddress, uniqueConnection.Settings.WifiSendPort }; int retryCount = 0; while (true) { if (uniqueConnection.Settings.Write(settingsToBeWritten, reporter, timeout, 0) == CommunicationProcessResult.Success) { break; } else if (retryCount++ <= retryLimit) { Commands.Send(uniqueConnection, Command.Apply, 0, 0); } else { throw new Exception("Device send IP address and/or port could not be configured for unique connection."); } } } finally { uniqueConnection.Close(); if (reporter != null) { uniqueConnection.Error -= reporter.OnError; uniqueConnection.Exception -= reporter.OnException; uniqueConnection.Info -= reporter.OnInfo; uniqueConnection.Message -= reporter.OnMessage; } } return(uniqueConnectionInfo); }
/// <summary> /// Process a single command synchronously. Note: This method will block until the process is complete. /// </summary> /// <param name="reporter">Progress reporter.</param> /// <param name="command">Command.</param> /// <param name="args">OSC message arguments</param> /// <returns>The result of the process.</returns> public CommunicationProcessResult SendCommand <T>(IReporter reporter, Command command, out T result, params object[] args) { return(Commands.Send(this, reporter, command, out result, args)); }
/// <summary> /// Process a single command synchronously. Note: This method will block until the process is complete. /// </summary> /// <param name="reporter">Progress reporter.</param> /// <param name="command">Command.</param> /// <returns>The result of the process.</returns> public CommunicationProcessResult SendCommand <T>(IReporter reporter, Command command, out T result) { return(Commands.Send(this, reporter, command, out result)); }
/// <summary> /// Process a single command synchronously. Note: This method will block until the process is complete. /// </summary> /// <param name="reporter">Progress reporter.</param> /// <param name="command">Command.</param> /// <returns>The result of the process.</returns> public CommunicationProcessResult SendCommand(IReporter reporter, Command command) { return(Commands.Send(this, reporter, command)); }
/// <summary> /// Process a single command synchronously. Note: This method will block until the process is complete. /// </summary> /// <param name="command">Command.</param> /// <param name="timeout">The timeout.</param> /// <param name="retryLimit">The retry limit.</param> /// <param name="args">OSC message arguments</param> /// <returns>The result of the process.</returns> public CommunicationProcessResult SendCommand(Command command, int timeout, int retryLimit, params object[] args) { return(Commands.Send(this, command, timeout, retryLimit, args)); }
/// <summary> /// Process a single command synchronously. Note: This method will block until the process is complete. /// </summary> /// <param name="command">Command.</param> /// <param name="args">OSC message arguments</param> /// <returns>The result of the process.</returns> public CommunicationProcessResult SendCommand(Command command, params object[] args) { return(Commands.Send(this, command, args)); }
/// <summary> /// Process a single command synchronously. Note: This method will block until the process is complete. /// </summary> /// <param name="command">Command.</param> /// <returns>The result of the process.</returns> public CommunicationProcessResult SendCommand(Command command) { return(Commands.Send(this, command)); }