/// <summary> /// Constructor accepts ip and port to listen for messages on. /// </summary> public OSCListener(int port) { ListenEndPoint = NetUtil.CreateIPEndPoint(OSCSettings.SourceIP, port); Server = new OscServer(TransportType.Udp, ListenEndPoint.Address, ListenEndPoint.Port); Server.FilterRegisteredMethods = false; Server.MessageReceived += OnMessageReceived; Server.Start(); }
private void initOscServer() { if (!oscServer.IsRunning) { oscServer.Start(); oscServer.BundleReceived += oscBundleReceived; } }
public void Initialise() { var server = new OscServer(TransportType.Udp, IPAddress.Loopback, Convert.ToInt32(ConfigurationManager.AppSettings["ListenOnPort"])); server.RegisterMethod("/"); server.MessageReceived += MessageReceived; server.Start(); }
public void Start() { if (oscServer == null) { oscServer = new OscServer(Bespoke.Common.Net.TransportType.Udp, IPAddress.Any, PortSetting.Value); oscServer.Start(); oscServer.BundleReceived += oscBundleReceived; PortSetting.ValueChanged += PortSetting_ValueChanged; } }
void Initialize() { if (server == null) { server = new OscServer(IPAddress.Parse(address), port, TransmissionType.Broadcast); server.FilterRegisteredMethods = false; server.Start(); Debug.Log(string.Format("[Messenger] initialized {0}:{1}", address, port)); } }
/// <summary> /// Constructor sets up end points for sending and receiving /// UDP communications with a remote Reaktor session and /// starts listening for OSC messages. /// </summary> public LaunchpadOSC(string listenIP, string remoteIP) { ListenEndPoint = NetUtil.CreateIPEndPoint(listenIP, ListenPort); TargetEndPoint = NetUtil.CreateIPEndPoint(remoteIP, Port); OscPacket.UdpClient = new UdpClient(SourcePort); Server = new OscServer(TransportType.Udp, ListenEndPoint.Address, ListenEndPoint.Port); Server.FilterRegisteredMethods = false; Server.MessageReceived += OnMessageReceived; Server.Start(); }
private void initOSC(MessageReceivedCallback messageReceivedCallback) { this.mrc = messageReceivedCallback; solidworksPlugin = new IPEndPoint(IPAddress.Loopback, SENDPORT); openFrameworks = new IPEndPoint(IPAddress.Loopback, SENDPORT); server = new OscServer(TransportType.Udp, IPAddress.Loopback, RECEIVEPORT); server.FilterRegisteredMethods = false; server.MessageReceived += new EventHandler <OscMessageReceivedEventArgs>(receivedMessage); server.ConsumeParsingExceptions = false; server.Start(); }
void setupOSC() { //OSC kinectServer1 = new OscServer(TransportType.Udp, IPAddress.Any, kinectPort1, kinectAddress1, Bespoke.Common.Net.TransmissionType.Unicast); kinectServer2 = new OscServer(TransportType.Udp, IPAddress.Any, kinectPort2, kinectAddress2, Bespoke.Common.Net.TransmissionType.Unicast); kinectServer1.FilterRegisteredMethods = true; kinectServer1.BundleReceived += new OscBundleReceivedHandler(kinect1Updated); kinectServer2.BundleReceived += new OscBundleReceivedHandler(kinect2Updated); //start listening kinectServer1.Start(); kinectServer2.Start(); }
private void btn_Click(object sender, EventArgs e) { if (osc_server.IsRunning) { osc_server.Stop(); ipaddress = osc_server.IPAddress.ToString(); toolStripStatusLabel1.Text = "Not Connected: " + ipaddress; } else { osc_server.Start(); toolStripStatusLabel1.Text = "Connected: " + ipaddress; } }
public InputServer(ILog log, IInputController inputController) { this.log = log; this.inputController = inputController; server = new OscServer(TransportType.Udp, IPAddress.Any, DEFAULT_VIP_PORT); server.RegisterMethod(JOYPAD_BUTTON_EVENT); server.RegisterMethod(MOUSE_EVENT); server.RegisterMethod(SCROLL_EVENT); server.RegisterMethod(KEYBOARD_EVENT); server.RegisterMethod(VOLUME_EVENT); server.MessageReceived += new OscMessageReceivedHandler(server_MessageReceived); server.Start(); log.Log(LogLevel.Info, "Starting Input Server"); }
public void Start() { if (_oscDevice.DeviceType == eOSCDeviceType.OSCServer && _oscServer != null) { _oscServer.BundleReceived += new EventHandler <OscBundleReceivedEventArgs>(oscServer_BundleReceived); _oscServer.MessageReceived += new EventHandler <OscMessageReceivedEventArgs>(oscServer_MessageReceived); _oscServer.ReceiveErrored += new EventHandler <ExceptionEventArgs>(oscServer_ReceiveErrored); _oscServer.Start(); } else if (_oscDevice.DeviceType == eOSCDeviceType.OSCClient) { sendDebugMessage(String.Format("Server started, connected to {0} ...", _oscDevice.Name), _oscDevice.IpAddress, _oscDevice.SendPort); } }
// public IPAddress BroadcastAddress { // get { // return IPAddress.Broadcast; // } // } public void Initialize() { if (server != null) { if (server.IsRunning) { server.Stop(); } } server = new OscServer(IPAddress.Parse("255.255.255.255"), Port, TransmissionType.Broadcast); server.FilterRegisteredMethods = false; server.Start(); server.MessageReceived += HandleMessageReceived; }
static void Main(string[] args) { OscPacket.LittleEndianByteOrder = false; sOscServer = new OscServer(TransportType.Udp, IPAddress.Parse("127.0.0.1"), 6250); sOscServer.BundleReceived += new OscBundleReceivedHandler(sOscServer_BundleReceived); sOscServer.MessageReceived += new OscMessageReceivedHandler(sOscServer_MessageReceived); sOscServer.FilterRegisteredMethods = false; sOscServer.Start(); Console.WriteLine("OSC Client: " + sOscServer.TransmissionType.ToString()); Console.WriteLine("Press any key to exit."); Console.ReadKey(); sOscServer.Stop(); }
public static void Main(string[] args) { OscServer oscServer; DemoType demoType = GetDemoType(); //IPAddress ipAddress = IPAddress.Loopback; //IPAddress ipAddress = IPAddress.Parse("192.168.1.118"); IPAddress ipAddress = IPAddress.Parse(Properties.Settings.Default.IPAddress); switch (demoType) { case DemoType.Udp: oscServer = new OscServer(TransportType.Udp, ipAddress, Properties.Settings.Default.Port); break; case DemoType.Tcp: oscServer = new OscServer(TransportType.Tcp, ipAddress, Properties.Settings.Default.Port); break; case DemoType.Multicast: oscServer = new OscServer(IPAddress.Parse("224.25.26.27"), Properties.Settings.Default.Port); break; default: throw new Exception("Unsupported receiver type."); } oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.RegisterMethod(PingMethod); // used by TouchOSC oscServer.BundleReceived += new EventHandler <OscBundleReceivedEventArgs>(oscServer_BundleReceived); oscServer.MessageReceived += new EventHandler <OscMessageReceivedEventArgs>(oscServer_MessageReceived); oscServer.ReceiveErrored += new EventHandler <ExceptionEventArgs>(oscServer_ReceiveErrored); oscServer.ConsumeParsingExceptions = false; oscServer.Start(); Console.WriteLine("Osc Receiver: " + demoType.ToString()); Console.WriteLine("with IP Address={0} on Port={1}", ipAddress, Properties.Settings.Default.Port); Console.WriteLine("Press any key to exit."); Console.ReadKey(); oscServer.Stop(); }
public void SendAndReceiveMessage() { using (var server = new OscServer(9001, new IPEndPoint(IPAddress.Any, 0))) using (var client = new OscClient(new IPEndPoint(IPAddress.Loopback, 9001))) { var method = new OscMethod(new OscAddress("/abc"), Callback); server.AddMethods(method); server.Start(); var addressPattern = new OscAddressPattern("/abc"); var arguments = new OscValue[] { new OscString("Hello World.") }; var message = new OscMessage(addressPattern, arguments); client.Send(message); Thread.Sleep(100); } Assert.True(messageReceived); }
public static void Main(string[] args) { OscServer oscServer; DemoType demoType = GetDemoType(); switch (demoType) { case DemoType.Udp: oscServer = new OscServer(TransportType.Udp, IPAddress.Loopback, Port); break; case DemoType.Tcp: oscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, Port); break; case DemoType.Multicast: oscServer = new OscServer(IPAddress.Parse("224.25.26.27"), Port); break; default: throw new Exception("Unsupported receiver type."); } oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.BundleReceived += new EventHandler <OscBundleReceivedEventArgs>(oscServer_BundleReceived); oscServer.MessageReceived += new EventHandler <OscMessageReceivedEventArgs>(oscServer_MessageReceived); oscServer.ReceiveErrored += new EventHandler <ExceptionEventArgs>(oscServer_ReceiveErrored); oscServer.ConsumeParsingExceptions = false; oscServer.Start(); Console.WriteLine("Osc Receiver: " + demoType.ToString()); Console.WriteLine("Press any key to exit."); Console.ReadKey(); oscServer.Stop(); }
public static void Main(string[] args) { OscServer oscServer; DemoType demoType = /*GetDemoType();*/ DemoType.Udp; switch (demoType) { case DemoType.Udp: oscServer = new OscServer(TransportType.Udp, IPAddress.Any, Port); break; case DemoType.Tcp: oscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, Port); break; case DemoType.Multicast: oscServer = new OscServer(IPAddress.Parse("224.25.26.27"), Port); break; default: throw new Exception("Unsupported receiver type."); } oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.RegisterMethod(MouseMethod); oscServer.BundleReceived += new EventHandler <OscBundleReceivedEventArgs>(oscServer_BundleReceived); oscServer.MessageReceived += new EventHandler <OscMessageReceivedEventArgs>(oscServer_MessageReceived); oscServer.ReceiveErrored += new EventHandler <ExceptionEventArgs>(oscServer_ReceiveErrored); oscServer.ConsumeParsingExceptions = false; handsets = new VirtualHandset[HANDSET_COUNT]; motorMin = new int[HANDSET_COUNT]; motorMax = new int[HANDSET_COUNT]; String[] comPorts = { "COM9", "COM4", "COM5", "COM6", "COM7", "COM8" }; for (int i = 0; i < HANDSET_COUNT; i++) { VirtualHandset handset = new VirtualHandset(); int result = handset.Connect(comPorts[i]); if (result != 0) { // -20 = virtual com port device not found (USB unplugged) // -30 = com port found but couldn't connect to hardware Console.WriteLine("error " + result + " opening " + comPorts[i]); continue; } VirtualHandset.ControlUnitSettings settings = new VirtualHandset.ControlUnitSettings(); result = handset.GetAllSettings(ref settings); if (result == 0) { Console.Write(comPorts[i] + ": OEM Information: " + (char)settings.OEMInformation[0] + " " + (char)settings.OEMInformation[1] + " " + (char)settings.OEMInformation[2] + " " + (char)settings.OEMInformation[3] + " (" + (settings.OEMInformation.Length - 4) + " more) "); } else { Console.WriteLine("error " + result + " getting control unit settings for " + comPorts[i]); continue; } int handsetIndex = 0; if ((char)settings.OEMInformation[0] == 'L') { handsetIndex = 0; } else if ((char)settings.OEMInformation[0] == 'R') { handsetIndex = 3; } else { Console.WriteLine(comPorts[i] + ": invalid OEMInformation[0] '" + (char)settings.OEMInformation[0] + "' (should be 'L' or 'R')"); continue; } if ((char)settings.OEMInformation[1] == '1') { handsetIndex += 0; } else if ((char)settings.OEMInformation[1] == '2') { handsetIndex += 1; } else if ((char)settings.OEMInformation[1] == '3') { handsetIndex += 2; } else { Console.WriteLine(comPorts[i] + ": invalid OEMInformation[1] '" + (char)settings.OEMInformation[1] + "' (should be '1', '2' or '3')"); continue; } handsets[handsetIndex] = handset; motorMin[handsetIndex] = settings.LowerLimit[0] + 1; // don't drive right to the very limit motorMax[handsetIndex] = settings.UpperLimit[0] - 1; // don't drive right to the very limit Console.WriteLine(" lower " + motorMin[handsetIndex] + " upper " + motorMax[handsetIndex]); Console.WriteLine(" -> assigning handset to index " + handsetIndex); // add event-handler for synchronizing the PC after driving //handsets[handsetIndex].OnSynchronizeAfterDriving += new VirtualHandset.OnSynchronizeAfterDrivingDelegate(onSynchronizeAfterDriving); } for (int i = 0; i < HANDSET_COUNT; i++) { if (handsets[i] == null) { Console.WriteLine("handset " + i + " missing, filling in with dummy"); handsets[i] = new VirtualHandset(); } // moveMotorToPosition(i, INITIAL_POS); } oscServer.Start(); // figure out my ip address IPHostEntry host; string localIP = "?"; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily.ToString() == "InterNetwork") { localIP = ip.ToString(); } } Console.WriteLine("Osc Receiver: " + demoType.ToString() + " listening on address " + localIP + " port " + Port); Console.WriteLine("Press any key to exit."); Console.ReadKey(); oscServer.Stop(); for (int i = 0; i < HANDSET_COUNT; i++) { if (handsets[i] == null) { continue; } handsets[i].Disconnect(); handsets[i].Dispose(); } }
public static Boolean Initialize() { try { if (!m_boolInitialized && !m_boolInitError) { // Check if Muse-IO is running // Launch Muse-IO String musePath = ""; if (File.Exists(@"C:\Program Files (x86)\Muse\muse-io.exe")) { musePath = @"C:\Program Files (x86)\Muse\muse-io.exe"; } else if (File.Exists(@"C:\Program Files\Muse\muse-io.exe")) { musePath = @"C:\Program Files\Muse\muse-io.exe"; } else { if (MessageBox.Show("Could not find Muse-IO. Would you like to install it?", "Install Muse SDK", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { System.Diagnostics.Process.Start("http://storage.googleapis.com/musesdk/musesdk-2.4.2-windows-installer.exe"); } else { MessageBox.Show("You can manually launch Muse-IO with this command: \r\nmuse-io --preset 14 --device Muse --osc osc.tcp://localhost:5000", "Muse IO Command Line", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } } if (musePath != "") { museIO = Process.Start(musePath, "muse-io --preset 14 --osc osc.tcp://localhost:5000"); } oscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, 5000); oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.BundleReceived += oscServer_BundleReceived; oscServer.MessageReceived += oscServer_MessageReceived; oscServer.ConsumeParsingExceptions = false; oscServer.Start(); m_boolInitialized = true; return(true); } if (m_boolInitialized) { return(true); } } catch (Exception ex) { m_boolInitError = true; throw (new Exception("The 'Muse' plugin failed to initialize: " + ex.Message)); } return(false); }
private void oscStart() { buttonOscStartStop.Text = "Stop OSC"; casparCgOscServer.Start(); }
private static void Main(string[] args) { OscPacket.UdpClient = new UdpClient(); ManualResetEventSlim manualResetEventSlim = new ManualResetEventSlim(false); if (!args.Any(argument => Regex.IsMatch(argument, @"--fis:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:,\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})*"))) { Console.WriteLine($"Usage: {Assembly.GetExecutingAssembly().GetName().Name} --fis:xxx.xxx.xxx.xxx[,xxx.xxx.xxx.xxx...] --ws:xxxx --oi:xxxx --hrt:xxxx --minhr:xxxx --maxhr:xxxx --log"); Console.WriteLine($"Example: {Assembly.GetExecutingAssembly().GetName().Name} --fis:192.168.1.30,192.168.1.42 --ws:100 --oi:125 --hrt:25 --minhr:40 --maxhr:150 --log"); return; } IPAddress[] forwardingIPs; int interval = 125; int windowSize = 50; bool log = false; int heartRateThreshold = 25; int minimumHeartRate = 40; int maximumHeartRate = 150; try { interval = int.Parse(args.Single(argument => Regex.IsMatch(argument, @"--io:\d{1,5}")).Split(":")[1].Trim()); } catch { // } try { windowSize = int.Parse(args.Single(argument => Regex.IsMatch(argument, @"--ws:\d{1,5}")).Split(":")[1].Trim()); } catch { // } try { heartRateThreshold = int.Parse(args.Single(argument => Regex.IsMatch(argument, @"--hrt:\d{1,5}")).Split(":")[1].Trim()); } catch { // } try { minimumHeartRate = int.Parse(args.Single(argument => Regex.IsMatch(argument, @"--minhr:\d{1,5}")).Split(":")[1].Trim()); } catch { // } try { maximumHeartRate = int.Parse(args.Single(argument => Regex.IsMatch(argument, @"--maxhr:\d{1,5}")).Split(":")[1].Trim()); } catch { // } try { log = args.Any(argument => Regex.IsMatch(argument, @"--log")); } catch { // } Processor processor = new Processor(windowSize); try { forwardingIPs = args.Single(argument => Regex.IsMatch(argument, @"--fis:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:,\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})*")).Split(":")[1].Trim().Split(",").Select(IPAddress.Parse).ToArray(); } catch { Console.WriteLine("Error: Problem with 'Forwarding IP Addresses'."); return; } Pulser pulser = new Pulser(windowSize, forwardingIPs, heartRateThreshold, maximumHeartRate, minimumHeartRate); OscServer oscServer = new OscServer(TransportType.Udp, IPAddress.Any, 8888); oscServer.PacketReceived += (sender, eventArgs) => { try { processor.InsertOscPacket(eventArgs.Packet); Task.Run(() => { if (eventArgs.Packet.Address.StartsWith("/person") && eventArgs.Packet.Address.EndsWith("/bpm")) { int person = int.Parse(eventArgs.Packet.Address.Split("/person")[1].Split("/")[0]); int bpm = eventArgs.Packet.At <int>(0); switch (person) { case 1: { pulser.Push1(bpm); break; } case 2: { pulser.Push2(bpm); break; } case 3: { pulser.Push3(bpm); break; } } } }); } catch (Exception e) { Console.WriteLine($"OSC Packet Error: {e.Message}"); } }; try { oscServer.Start(); } catch { Console.WriteLine("Error: Couldn't start the OSC server, probably because of a problem in 'Listening IP Address'."); return; } UdpServer <int> emotionListener = new UdpServer <int>(8877, manualResetEventSlim, "Emotion"); emotionListener.DataReceived += (sender, data) => { try { processor.InsertEmotion(data); } catch (Exception e) { Console.WriteLine($"Emotion Error: {e.Message}"); } }; emotionListener.Start(); UdpServer <int> reasonListener = new UdpServer <int>(8899, manualResetEventSlim, "Reason"); reasonListener.DataReceived += (sender, data) => { try { processor.InsertReason(data); } catch (Exception e) { Console.WriteLine($"Reason Error: {e.Message}"); } }; reasonListener.Start(); Broadcaster broadcaster = new Broadcaster(interval, processor, forwardingIPs); broadcaster.Start(); if (log) { Task.Run(() => { while (!manualResetEventSlim.IsSet) { Console.Clear(); Console.BackgroundColor = ConsoleColor.DarkGray; Console.ForegroundColor = ConsoleColor.DarkRed; pulser.Log(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.DarkBlue; emotionListener.Log(); reasonListener.Log(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; processor.Log(); Thread.Sleep(125); } }); } manualResetEventSlim.Wait(); }