private void Connect_Click(object sender, EventArgs e) { // if there is already an instace dispose of it if (m_Receiver != null) { // dispose of the reciever AppendLine("Disconnecting"); m_Receiver.Dispose(); // wait for the thread to exit (IMPORTANT!) m_Thread.Join(); m_Receiver = null; } // get the ip address from the address box string addressString = m_AddressBox.Text; IPAddress ipAddress; // parse the ip address if (addressString.Trim().Equals("Any", StringComparison.InvariantCultureIgnoreCase) == true) { ipAddress = IPAddress.Any; } else if (IPAddress.TryParse(addressString, out ipAddress) == false) { AppendLine(String.Format("Invalid IP address, {0}", addressString)); return; } // create the reciever instance m_Receiver = new OscReceiver(ipAddress, (int)m_PortBox.Value); // tell the user AppendLine(String.Format("Listening on: {0}:{1}", ipAddress, (int)m_PortBox.Value)); try { // connect to the socket m_Receiver.Connect(); } catch (Exception ex) { this.Invoke(new StringEvent(AppendLine), "Exception while connecting"); this.Invoke(new StringEvent(AppendLine), ex.Message); m_Receiver.Dispose(); m_Receiver = null; return; } // create the listen thread m_Thread = new Thread(ListenLoop); // start listening m_Thread.Start(); }
private void Connect_Click(object sender, EventArgs e) { // if there is already an instace dispose of it if (m_Receiver != null) { // disable the timer m_MessageCheckTimer.Enabled = false; // dispose of the reciever AppendLine("Disconnecting"); m_Receiver.Dispose(); m_Receiver = null; } // get the ip address from the address box string addressString = m_AddressBox.Text; IPAddress ipAddress; // parse the ip address if (addressString.Trim().Equals("Any", StringComparison.InvariantCultureIgnoreCase) == true) { ipAddress = IPAddress.Any; } else if (IPAddress.TryParse(addressString, out ipAddress) == false) { AppendLine(String.Format("Invalid IP address, {0}", addressString)); return; } // create the reciever instance m_Receiver = new OscReceiver(ipAddress, (int)m_PortBox.Value); // tell the user AppendLine(String.Format("Listening on: {0}:{1}", ipAddress, (int)m_PortBox.Value)); try { // connect to the socket m_Receiver.Connect(); } catch (Exception ex) { AppendLine("Exception while connecting"); AppendLine(ex.Message); m_Receiver.Dispose(); m_Receiver = null; return; } // enable the timer m_MessageCheckTimer.Enabled = true; }
private void ReconnectListener(int port) { if (_receiver?.State == OscSocketState.Connected) { _receiver.Close(); } _receiveTask?.Wait(); _receiveTask?.Dispose(); _receiver?.Dispose(); _receiver = new OscReceiver(port); _receiver.Connect(); _receiveTask = Task.Run(async() => await ListenLoop()); }
public void Stop() { _isStopping = true; _resolumeOscSender.Dispose(); _resolumeOscReceiver.Dispose(); if (!_listenerThread.Join(1500)) { _listenerThread.Abort(); } }
public void Dispose() { if (!_isDisposed) { _isDisposed = true; _sender.Close(); _sender.Dispose(); _reciever.Close(); _reciever.Dispose(); } }
private void Disconnect() { // If the receiver exists if (m_Receiver != null) { // Disconnect the receiver Debug.Log("Disconnecting Receiver"); m_Receiver.Dispose(); // Nullifiy the receiver m_Receiver = null; } }
public void Dispose() { OscReceiver.Dispose(); OscAddressManager.Dispose(); }
public override void Dispose() { oscReceiver.Dispose(); oscSender.Dispose(); }