static void Main(string[] args) { m_Listener = new OscAddressManager(); m_Listener.Attach("/testA", TestMethodA); m_Listener.Attach("/testB", TestMethodB); m_Receiver = new OscReceiver(IPAddress.IPv6Any, IPAddress.Parse("FF02::2"), 12345); m_Sender = new OscSender(IPAddress.Parse("FF02::2"), 12345); m_Thread = new Thread(new ThreadStart(ListenLoop)); Console.WriteLine("Connecting"); m_Receiver.Connect(); m_Sender.Connect(); m_Thread.Start(); Console.WriteLine(); Console.WriteLine("Sending message to A"); Console.WriteLine(); m_Sender.Send(new OscMessage("/testA", "Hello from sender (test1)")); Thread.CurrentThread.Join(100); Console.WriteLine(); Console.WriteLine("Press any key to send the next message"); Console.ReadKey(true); Console.WriteLine(); Console.WriteLine("Sending message to B"); Console.WriteLine(); m_Sender.Send(new OscMessage("/testB", "Hello from sender (test2)")); Thread.CurrentThread.Join(100); Console.WriteLine(); Console.WriteLine("Press any key to send the next message"); Console.ReadKey(true); Console.WriteLine(); Console.WriteLine("Sending message to A and B"); Console.WriteLine(); m_Sender.Send(new OscMessage("/*", "Hello from sender (test3)")); Thread.CurrentThread.Join(100); Console.WriteLine(); Console.WriteLine("Press any key to exit"); Console.ReadKey(true); Console.WriteLine("Shutting down"); m_Receiver.Close(); m_Thread.Join(); m_Sender.Close(); }
public void Dispose() { _receiver?.Close(); _sender?.Close(); _receiveTask?.Wait(); _receiver?.Dispose(); _sender?.Close(); }
public void StopListening() { if (_oscReveiver?.State == OscSocketState.Connected) { _cancelationTokenSource.Cancel(); _oscReveiver?.Close(); ListenerStopped?.Invoke(this, EventArgs.Empty); } }
//! Disconnect the state listener public void Disconnect() { if (receiver != null) { receiver.Close(); } receiver = null; connected = false; }
//受信待受停止 public void Dispose() { //待受停止 try { oscReceiver?.Close(); } finally{ //Thread終了を待機 thread?.Join(); } }
public void Dispose() { if (!_isDisposed) { _isDisposed = true; _sender.Close(); _sender.Dispose(); _reciever.Close(); _reciever.Dispose(); } }
// Override the OnClosed method to close the receiver. protected override void OnClosed(EventArgs e) { // Close the receiver and the thread. Receiver.Close(); OscThread.Abort(); // Perform normal closing procedures. base.OnClosed(e); // Shutdown the application. Application.Current.Shutdown(); }
public static void Close() { try { receiver.Close(); oscWorker.CancelAsync(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
//受信待受停止 public void Dispose() { //待受停止 try { oscReceiver?.Close(); oscSender?.Close(); } finally { //Thread終了を1500msの間待機 thread?.Join(1500); } }
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()); }
/// <summary> /// Receives the next available OSC packet, splits the csv data values, and stores into a string array /// </summary> public void GetOSCPacket() { try { if (_OSCReceiver.State == OscSocketState.Connected) { OscPacket packet = _OSCReceiver.Receive(); _OSCPacket = packet.ToString().Split(','); } } catch (Exception e) { Debug.Log(e.Message); _OSCReceiver.Close(); } }
/// <summary> /// Receives the next available OSC packet relative to the Pozyx TagID, /// splits the csv data values, and stores into a string array /// </summary> public static string[] GetOSCPacket(string tagID) { OscPacket packet; string[] extractData = null; const string START_LINE = "/position"; bool gotCorrectPacket = false; // Attempt to establish an OSC connection and receive packet try { // Connect to OSC _OSCReceiver.Connect(); do { if (_OSCReceiver.State == OscSocketState.Connected) { // Attempt to receive OSC packet packet = _OSCReceiver.Receive(); // Extract data from OSC packet if (packet.ToString().StartsWith(START_LINE)) { extractData = packet.ToString().Split(','); // Multi-Tag Functionality // Checks packet "TagID" matches GameObject "TagID" (in Hexadecimal) if (Convert.ToInt32(extractData[1]).ToString("X") == tagID) { gotCorrectPacket = true; } } } } while (!gotCorrectPacket); // Close OSC _OSCReceiver.Close(); } catch (Exception e) { Debug.Log(e.Message); } return(extractData); }
static void Main(string[] args) { IPAddress IPaddress = IPAddress.Parse("127.0.0.1"); int port = 8888; OscReceiver oscReceiver = new OscReceiver(IPaddress, port); oscReceiver.Connect(); Console.Write("Waiting for OSC connection...\n\n"); StartLoop(oscReceiver); oscReceiver.Close(); Console.WriteLine("OSC Connection closed."); Console.ReadKey(); }
private void FormTerminal_FormClosing(object sender, FormClosingEventArgs e) { oscReceiver.Close(); thread.Join(); }
public override void Close() { try { oscReceiver.Close(); } catch { } try { oscSender.Close(); } catch { } }
public void StopReceiving() { oscReceiver.Close(); receivingThread.Join(); }
public void Close() { OscReceiver.Close(); }
private void Window_Closed(object sender, EventArgs e) { oscReceiver.Close(); thread.Join(); }
public void Dispose() { _client?.Close(); _client?.Dispose(); _server.Close(); }
public void Dispose() { _server.Close(); }
public void Close() { _receiver.Close(); _listenerThread.Join(); }