static void Main(string[] args) { Console.WriteLine("OSC Client."); Console.WriteLine("周波数[Hz] 再生時間[msec]"); // 送信先はローカルホスト var address = IPAddress.Parse("127.0.0.1"); // 送信先のポートを指定 using var oscSender = new OscSender(address, 2345); // 接続 oscSender.Connect(); //// 無限ループにしてメッセージ送信 //while (true) //{ // var msg = Console.ReadLine(); // oscSender.Send(new OscMessage("/test", msg.ToString())); //} while (true) { var msg = Console.ReadLine().Split(" "); if (int.TryParse(msg[0], out int freq) && int.TryParse(msg[1], out int time)) { //Console.Beep(freq, time); oscSender.Send(new OscMessage("/beep", freq, time)); } } }
public void Start() { _listenerThread.Start(); _resolumeOscReceiver.Connect(); _resolumeOscSender.Connect(); _mutatorThread.Start(); }
public void SendTest() { try { // This is the ip address we are going to send to IPAddress address = IPAddress.Loopback; // This is the port we are going to send to int port = 12345; // Create a new sender instance using (OscSender sender = new OscSender(address, port)) { // Connect the sender socket sender.Connect(); // Send a new message sender.Send(new OscMessage("/test", 1, 2, 3, 4)); } } catch (Exception ex) { Assert.Fail(ex.Message); } }
public MainWindow() { InitializeComponent(); applicationState = ApplicationState.MaskCreation; filteredPLayerIndexes = new List <int>(); oldTrackingValues = new Dictionary <int, Tuple <int, int> >(); kinect1Mask = new byte[width * height]; kinect2Mask = new byte[width * height]; oscHandler = new OscHandler(5106); oscHandler.OnDataReceived += data => NewKinectData(data, ref kinect1Mask, oscHandler.Port); oscHandler.StartReceiving(); oscHandler2 = new OscHandler(5107); oscHandler2.OnDataReceived += data => NewKinectData(data, ref kinect2Mask, oscHandler2.Port); oscHandler2.StartReceiving(); oscSender = new OscSender(IPAddress.Parse(oscSendAddr), 0, oscSendPort); oscSender.Connect(); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += UpdateImageSources; timer.Start(); //KinectImage.Source = img; }
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 virtual void Connect() { if (!_isDisposed) { _sender.Connect(); _reciever.Connect(); } }
private void sendvalue(string s, int i) { using (OscSender sender = new OscSender(IPAddress.Parse("192.168.1.75"), 3032)) { sender.Connect(); sender.Send(new OscMessage(s, i)); } }
private void OpenSender(ushort port, IPAddress ipAddress) { // Update port/IP list if (!sendPorts.Contains(port)) { sendPorts.Add(port); sendPorts.Sort(); } if (!ipAddressStrings.Contains(ipAddress.ToString())) { ipAddressStrings.Add(ipAddress.ToString()); ipAddressStrings.Sort(); } toolStripMenuItemSendPortIP.DropDownItems.Clear(); foreach (ushort p in sendPorts) { toolStripMenuItemSendPortIP.DropDownItems.Add(p.ToString()); } toolStripMenuItemSendPortIP.DropDownItems.Add("..."); toolStripMenuItemSendPortIP.DropDownItems.Add("-"); foreach (string s in ipAddressStrings) { toolStripMenuItemSendPortIP.DropDownItems.Add(s); } toolStripMenuItemSendPortIP.DropDownItems.Add("..."); // Check selected port/IP foreach (object o in toolStripMenuItemSendPortIP.DropDownItems) { if (o is ToolStripMenuItem) { ToolStripMenuItem toolStripMenuItem = (ToolStripMenuItem)o; if (toolStripMenuItem.Text == port.ToString()) { toolStripMenuItem.Checked = true; } if (toolStripMenuItem.Text == ipAddress.ToString()) { toolStripMenuItem.Checked = true; } } } // Open sender if (oscSender != null) { oscSender.Close(); } try { oscSender = new OscSender(ipAddress, port); oscSender.Connect(); } catch (Exception exception) { MessageBox.Show(exception.ToString()); } }
private void sendcommand(string s) { using (OscSender sender = new OscSender(IPAddress.Parse("192.168.1.75"), 3032)) { sender.Connect(); sender.Send(new OscMessage(s)); sender.Close(); } }
public void SendMessage(string str, int num) { var mess = new OscMessage(str, num); using (OscSender sender = new OscSender(address, port)) { sender.Connect(); sender.Send(mess); } }
public void Connect() { Disconnect(); sender = new OscSender(AdapterIPAddress, 0, SendIPAddress, SendPort); sender.Connect(); DisableAllControls(); }
// Use this for initialization void Start() { listener = new OscListener(IPAddress.Parse(ipAddress), recvPort); listener.Connect(); listener.Attach("/prediction", OnPrediction); sender = new OscSender(IPAddress.Parse(ipAddress), sendPort); sender.Connect(); }
private void InitializeClient() { if (_client != null) { _client?.Close(); _client?.Dispose(); } _client = new OscSender(IPAddress.Any, IPAddress.Loopback, _sys.Config.RequestPort); _client.Connect(); }
public OscHandler(string OscAddr) { //TODO: Use TryParse instead of parse var addr = IPAddress.Parse(OscAddr.Split(':')[0]); var port = int.Parse(OscAddr.Split(':')[1]); sender = new OscSender(addr, port); //TODO: Try catch for network exception sender.Connect(); }
public override void CreateNetwork() { IPAddress address = IPAddress.Broadcast; if (!string.IsNullOrEmpty(Addresse)) { address = IPAddress.Parse(Addresse); } sender = new OscSender(address, base.PortOut); sender.Connect(); }
public OutputOSC(string adr, int port) { this.Address = adr; this.Port = port; IPAddress ip = IPAddress.Parse(this.Address); oscSender = new OscSender(ip, 0, this.Port); oscSender.Connect(); //例外は上位に打ち上げる }
public void SendFermata() { var mess = new OscMessage(tempoAddr, 0); Console.WriteLine(string.Format("Sending tempo {0}", 0)); using (OscSender sender = new OscSender(address, port)) { sender.Connect(); sender.Send(mess); } }
static void Main(string[] args) { IPAddress remote = IPAddress.Parse("192.168.2.4"); int remotePort = 5000; if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { Console.WriteLine("No network connections available"); return; } // Get host name String strHostName = Dns.GetHostName(); // Find host by name IPHostEntry iphostentry = Dns.GetHostEntry(strHostName); NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface adapter in interfaces) { var ipProps = adapter.GetIPProperties(); foreach (var ip in ipProps.UnicastAddresses) { if ((adapter.OperationalStatus == OperationalStatus.Up) && (ip.Address.AddressFamily == AddressFamily.InterNetwork)) { Console.WriteLine(ip.Address.ToString().PadRight(20) + adapter.Description.ToString()); try { using (OscSender sender = new OscSender(ip.Address, remote, remotePort)) { sender.Connect(); sender.Send(new OscMessage("/test", 1, 2, 3)); } } catch (Exception ex) { Console.WriteLine("Exception while sending"); Console.WriteLine(ex.Message); } Console.WriteLine(); } } } Console.ReadKey(true); }
private void broadcastNewLocation(int i) { System.Console.WriteLine($"Position: {i}"); //labelSensor.Content = $"Sensor: {i}"; using (OscSender sender = new OscSender(Address, Port)) { sender.Connect(); sender.Send(new OscMessage("/quadrant", i)); } }
private void InitializeOsc() { try { oscSender = new OscSender(IPAddress.Parse(ipAddress), 0, this.remotePort, 600, 20000); oscSender.Connect(); } catch (Exception e) { Console.WriteLine("Exception on OSC connection..."); Console.WriteLine(e.StackTrace); } }
public void StartDataOut() { try { _sender = new OscSender(_userIP, _connectPort); _sender.Connect(); } catch (Exception e) { Console.WriteLine(e.ToString()); Logger.Debug(e.Message); } }
public void SendTempo(int t) { if (t != lastSentTempo) { var mess = new OscMessage(tempoAddr, t); Console.WriteLine(string.Format("Sending tempo {0}", t)); using (OscSender sender = new OscSender(address, port)) { sender.Connect(); sender.Send(mess); } lastSentTempo = t; } }
// Use this for initialization void Start() { listener = new OscListener(IPAddress.Parse(ipAddress), recvPort); listener.Connect(); listener.Attach("/prediction", OnPrediction); block = new MaterialPropertyBlock(); sender = new OscSender(IPAddress.Parse(ipAddress), sendPort); sender.Connect(); leftRenderer = leftHand.GetComponentInChildren <Renderer>(); rightRenderer = rightHand.GetComponentInChildren <Renderer>(); }
public override void Connect() { oscReceiver.Connect(); oscSender.Connect(); thread = new Thread(new ThreadStart(ReceiveLoop)); thread.Name = "Udp Connection Implementation Receive Loop" + udpConnectionInfo.ToString(); if (oscReceiver.State != OscSocketState.Connected && oscSender.State != OscSocketState.Connected) { throw new Exception(string.Format(Strings.UdpConnectionImplementation_FailedToConnect, udpConnectionInfo.ToString())); } connection.OnInfo(string.Format(Strings.UdpConnectionImplementation_Connected, udpConnectionInfo.ToString())); }
public void SendVolume(double v) { if (v != lastSentVolume) { int val = (int)(v * 100); var mess = new OscMessage(volumeAddr, val); Console.WriteLine(string.Format("Sending volume {0}", val)); using (OscSender sender = new OscSender(address, port)) { sender.Connect(); sender.Send(mess); } lastSentPan = v; } }
public void SendPan(double p) { if (p != lastSentPan) { int val = (int)(p * 100); var mess = new OscMessage(panAddr, val); Console.WriteLine(string.Format("Sending pan {0}", val)); using (OscSender sender = new OscSender(address, port)) { sender.Connect(); sender.Send(mess); } lastSentPan = p; } }
private void SendFunction(object sender, RoutedEventArgs e) { Console.WriteLine("送信処理"); // 送信先はローカルホスト var address = IPAddress.Parse("127.0.0.1"); // 送信先のポートを指定 using var oscSender = new OscSender(address, 2345); var msg = "from Wpf."; // 接続 oscSender.Connect(); oscSender.Send(new OscMessage("/test", msg)); viewModel.OscText = "asdfg"; viewModel.BgColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0xFF, 0x00)); }
private void Application_SlideShowNextClick(PowerPoint.SlideShowWindow Wn, PowerPoint.Effect nEffect) { //throw new NotImplementedException(); // PowerPointスライドの「ノート」部分を取得する。 string note = Wn.View.Slide.NotesPage.Shapes.Placeholders[2].TextFrame.TextRange.Text; string noteT = note.Trim(); if (noteT != "") { oscSender.Connect(); Debug.WriteLine("つなげた"); oscSender.Send(new OscMessage("/scene", noteT)); //oscSender.Send(new OscMessage("/change", int.Parse(noteT))); Debug.WriteLine(noteT + ":"); this.oscSender.Close(); Debug.WriteLine("とじた"); } }
private void Connect_Click(object sender, EventArgs e) { // if there is already an instace dispose of it if (m_Sender != null) { timer1.Enabled = false; AppendLine("Disconnecting"); m_Sender.Dispose(); m_Sender = null; } // get the ip address from the address box string addressString = m_AddressBox.Text; IPAddress ipAddress; // parse the ip address if (IPAddress.TryParse(addressString, out ipAddress) == false) { AppendLine(String.Format("Invalid IP address, {0}", addressString)); return; } // create the sender instance m_Sender = new OscSender(ipAddress, (int)m_PortBox.Value); // tell the user AppendLine(String.Format("Connecting to: {0}:{1}", ipAddress, (int)m_PortBox.Value)); try { // connect to the socket m_Sender.Connect(); } catch (Exception ex) { AppendLine("Exception while connecting"); AppendLine(ex.Message); m_Sender.Dispose(); m_Sender = null; } }
private void TryConnect() { foreach (var ipAddress in this.ipAddresses) { try { var oscSender = new OscSender(ipAddress, int.Parse(this.port)); oscSender.Connect(); this.oscSenders.Add(oscSender); this.status += "OSC connection established on\nIP: " + ipAddress + "\nPort: " + port + "\n"; } catch (Exception e) { this.status += "Unable to make OSC connection on\nIP: " + ipAddress + "\nPort: " + port + "\n"; Console.WriteLine("Exception on OSC connection..."); Console.WriteLine(e.StackTrace); } } }
private void TryConnect() { foreach(var ipAddress in this.ipAddresses) { try { var oscSender = new OscSender(ipAddress, int.Parse(this.port)); oscSender.Connect(); this.oscSenders.Add(oscSender); this.status += "OSC connection established on\nIP: " + ipAddress + "\nPort: " + port + "\n"; } catch (Exception e) { this.status += "Unable to make OSC connection on\nIP: " + ipAddress + "\nPort: " + port + "\n"; Console.WriteLine("Exception on OSC connection..."); Console.WriteLine(e.StackTrace); } } }
void Awake() { // Log the start Debug.Log("Starting Osc"); // Ensure that the sender is disconnected Disconnect(); // The address to send to IPAddress addess = IPAddress.Parse(RemoteAddress); // The port to send to int port = RemotePort; // Create an instance of the sender m_Sender = new OscSender(addess, 0, port); // Connect the sender m_Sender.Connect(); // We are now connected Debug.Log("Sender Connected"); }