Example #1
0
        private void _CreateConnection()
        {
            if (_oscReceiver != null)
            {
                _DeleteConnection();
            }
            _oscReceiver = new UniOSCReceiver(oscPort);
            if (Application.isPlaying)
            {
                _oscReceiver.OSCMessageReceived += OnOSCMessageReceived;
            }
            else
            {
                _oscReceiver.OSCMessageReceived += OnOSCMessageReceived;
            }

            //if(hasOSCSessionFileAttached){
            foreach (var osf in oscSessionFileObjList)
            {
                if (osf != null)
                {
                    OSCMessageReceivedRaw += osf.OnOSCMessageReceived;
                }
            }
            //}
        }
Example #2
0
        private void _DeleteConnection()
        {
            if (_oscReceiver == null)
            {
                return;
            }
            //Debug.Log("UniOSCConnection._DeleteConnection:"+oscPort);
            _oscReceiver.Disconnect();

            if (Application.isPlaying)
            {
                _oscReceiver.OSCMessageReceived -= OnOSCMessageReceived;
            }
            else
            {
                _oscReceiver.OSCMessageReceived -= OnOSCMessageReceived;
            }

            _oscReceiver = null;


            //if(hasOSCSessionFileAttached){
            foreach (var osf in oscSessionFileObjList)
            {
                if (osf != null)
                {
                    OSCMessageReceivedRaw -= osf.OnOSCMessageReceived;
                }
            }
            //}
        }
Example #3
0
        private void _CreateConnection()
        {
            // Debug.Log("_CreateConnection");
            if (_oscReceiver != null)
            {
                _DeleteConnection();
            }

            if (!hasValidOscIPAddress)
            {
                Debug.LogWarning(String.Format("<color='orange'>The connection on port: {0} with IP address {1} could not be established! (Invalid IP address)</color>", oscPort, oscInIPAddress));
                return;
            }


            switch (transmissionTypeIn)
            {
            case OSCsharp.Net.TransmissionType.Unicast:
                _oscReceiver = new UniOSCReceiver(oscPort, transmissionTypeIn, null);
                break;

            case OSCsharp.Net.TransmissionType.Multicast:

                if (oscInIPAddressAsIPAddress == null)
                {
                    Debug.LogWarning(String.Format("<color='orange'>The connection on port: {0} with IP address {1} could not be established! (Invalid Multicast address)</color>", oscPort, oscInIPAddress));
                    return;
                }
                _oscReceiver = new UniOSCReceiver(oscPort, transmissionTypeIn, oscInIPAddressAsIPAddress);
                break;

            default: return;
            }


            if (Application.isPlaying)
            {
                _oscReceiver.OSCMessageReceived += OnOSCMessageReceived;
            }
            else
            {
                _oscReceiver.OSCMessageReceived += OnOSCMessageReceived;
            }

            if (hasOSCSessionFileAttached)
            {
                foreach (var osf in oscSessionFileObjList)
                {
                    if (osf != null)
                    {
                        OSCMessageReceivedRaw += osf.OnOSCMessageReceived;
                    }
                }
            }
        }