static void Main(string[] args) { sOscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, 5253); 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() { var server = new OscServer(TransportType.Udp, IPAddress.Loopback, Convert.ToInt32(ConfigurationManager.AppSettings["ListenOnPort"])); server.RegisterMethod("/"); server.MessageReceived += MessageReceived; server.Start(); Console.WriteLine("Dummy Receiver started."); Console.WriteLine("Awaiting messages..."); Console.WriteLine("Press any key to exit."); Console.ReadKey(); server.Stop(); }
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(); 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(); } }