コード例 #1
0
        /// <summary>
        /// Event method, to receive nuvo control messages from osc devices.
        /// This method sends updates to all connected clients.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OscServer_onOscNuvoEventReceived(object sender, ProtocolDriver.Interface.OscEventReceivedEventArgs e)
        {
            sNuvoMessagesReceivedCount++;
            _log.Trace(m => m("OSCS: Device (id={0}) nuvo control event ({1}) from {2}: {3}", e.OscDevice, sNuvoMessagesReceivedCount, e.SourceEndPoint, e.OscEvent.ToString()));
            _oscDeviceLastUpdate[e.SourceEndPoint.Address] = DateTime.Now;

            bool bKnown = false;

            foreach (OscDeviceController oscDeviceController in _oscDeviceControllers.Values)
            {
                // forward message to clients
                oscDeviceController.processOscNuvoEventForClients(new Address(e.OscDeviceId, e.OscEvent.getZoneId), e.OscEvent);
                // forward (debug) message to clients
                //oscDeviceController.GetOscDriver().SendMessage("/NuvoControl/message", String.Format("Notify {0}/{1}: {2}", sMessagesReceivedCount, oscDeviceController.OscDeviceId, e.OscEvent.ToString()));
                // Check if client is "known"
                if (String.Compare(oscDeviceController.OscDevice.IpAddress.ToString(), e.SourceEndPoint.Address.ToString()) == 0)
                {
                    bKnown = true;
                }
            }

            // If client was/is not known ...
            if (!bKnown)
            {
                // ... create "ad-hoc" controller, to start updating this client, assuming the client listen to port 9000
                _log.Trace(m => m("OSCS.onOscNuvoEventReceived: Client {0} not known, add with id={1}!", e.SourceEndPoint, adhocDeviceIdCounter));
                lock (_oscDeviceControllers)
                {
                    Address             address   = new Address(e.OscDeviceId, adhocDeviceIdCounter);
                    OSCDevice           oscDevice = new OSCDevice(address, eOSCDeviceType.OSCClient, address, String.Format("AdHocClient{0}", adhocDeviceIdCounter), e.SourceEndPoint.Address, 8000, 9000, null);
                    OscDeviceController adhocOscDeviceController = new OscDeviceController(address, oscDevice, _oscDeviceControllers[e.OscDevice]);
                    _oscDeviceControllers.Add(address, adhocOscDeviceController);
                    adhocDeviceIdCounter--;
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Event method, to receive osc messages from osc devices.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void OscServer_onOscEventReceived(object sender, ProtocolDriver.Interface.OscEventReceivedEventArgs e)
 {
     sOscMessagesReceivedCount++;
     _log.Trace(m => m("OSCS: Device (id={0}) osc event ({1}) from {2}: {3}", e.OscDevice, sOscMessagesReceivedCount, e.SourceEndPoint, e.OscEvent.ToString()));
     _oscDeviceLastUpdate[e.SourceEndPoint.Address] = DateTime.Now;
 }