コード例 #1
0
        internal void Dispatch(string address, OscDataHandle data)
        {
            lock (_callbackMap)
            {
                // Address-specified callback
                if (_callbackMap.TryGetValue(address, out var callback))
                {
                    callback(address, data);
                }

                // Monitor callback
                if (_callbackMap.TryGetValue(string.Empty, out callback))
                {
                    callback(address, data);
                }
            }
        }
コード例 #2
0
        internal void Dispatch(string address, OscDataHandle data)
        {
            lock (_callbackMap)
            {
                MessageCallback callback;

                // Address-specified callback
                // RESOLINK - this is unused, so remove it
                //if (_callbackMap.TryGetValue(address, out callback))
                //    callback(address, data);

                // Monitor callback
                if (_callbackMap.TryGetValue(string.Empty, out callback))
                {
                    callback(address, data);
                }
            }
        }
        void MonitorCallback(string address, OscDataHandle data)
        {
            _stringBuilder.Length = 0;
            _stringBuilder.Append(address).Append(": ");

            var ecount = data.GetElementCount();

            for (var i = 0; i < ecount; i++)
            {
                _stringBuilder.Append(data.GetElementAsString(i));
                if (i < ecount - 1)
                {
                    _stringBuilder.Append(", ");
                }
            }

            _logLines[_logCount] = _stringBuilder.ToString();
            _logCount            = (_logCount + 1) % _logLines.Length;
        }
コード例 #4
0
        private void OnDataReceive(string address, OscDataHandle data)
        {
            switch (_dataType)
            {
            case DataType.None:
                _bangCount++;
                break;

            case DataType.Int:
                lock (_intQueue)
                    _intQueue.Enqueue(data.GetElementAsInt(0));
                break;

            case DataType.Float:
                lock (_floatQueue)
                    _floatQueue.Enqueue(data.GetElementAsFloat(0));
                break;

            case DataType.String:
                lock (_stringQueue)
                    _stringQueue.Enqueue(data.GetElementAsString(0));
                break;

            case DataType.Vector2:
                lock (_floatQueue)
                {
                    _floatQueue.Enqueue(data.GetElementAsFloat(0));
                    _floatQueue.Enqueue(data.GetElementAsFloat(1));
                }
                break;

            case DataType.Vector3:
                lock (_floatQueue)
                {
                    _floatQueue.Enqueue(data.GetElementAsFloat(0));
                    _floatQueue.Enqueue(data.GetElementAsFloat(1));
                    _floatQueue.Enqueue(data.GetElementAsFloat(2));
                }
                break;

            case DataType.Vector4:
                lock (_floatQueue)
                {
                    _floatQueue.Enqueue(data.GetElementAsFloat(0));
                    _floatQueue.Enqueue(data.GetElementAsFloat(1));
                    _floatQueue.Enqueue(data.GetElementAsFloat(2));
                    _floatQueue.Enqueue(data.GetElementAsFloat(3));
                }
                break;

            case DataType.Vector2Int:
                lock (_intQueue)
                {
                    _intQueue.Enqueue(data.GetElementAsInt(0));
                    _intQueue.Enqueue(data.GetElementAsInt(1));
                }
                break;

            case DataType.Vector3Int:
                lock (_intQueue)
                {
                    _intQueue.Enqueue(data.GetElementAsInt(0));
                    _intQueue.Enqueue(data.GetElementAsInt(1));
                    _intQueue.Enqueue(data.GetElementAsInt(2));
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #5
0
ファイル: OscEventReceiver.cs プロジェクト: oogre/OscJack
        void OnDataReceive(string address, OscDataHandle data)
        {
            switch (_dataType)
            {
            case DataType.None:
                _bangCount++;
                break;

            case DataType.Int:
                lock (_intQueue)
                    intData = data.GetElementAsInt(0);
                _intQueue.Enqueue(data.GetElementAsInt(0));
                break;

            case DataType.Float:
                lock (_floatQueue)
                    floatData = data.GetElementAsFloat(0);
                _floatQueue.Enqueue(data.GetElementAsFloat(0));
                break;

            case DataType.String:
                lock (_stringQueue)
                    stringData = data.GetElementAsString(0);
                _stringQueue.Enqueue(data.GetElementAsString(0));
                break;

            case DataType.Vector2:
                lock (_floatQueue)
                {
                    vector2Data.x = data.GetElementAsFloat(0);
                    vector2Data.y = data.GetElementAsFloat(1);
                    _floatQueue.Enqueue(data.GetElementAsFloat(0));
                    _floatQueue.Enqueue(data.GetElementAsFloat(1));
                }
                break;

            case DataType.Vector3:
                lock (_floatQueue)
                {
                    vector3Data.x = data.GetElementAsFloat(0);
                    vector3Data.y = data.GetElementAsFloat(1);
                    vector3Data.z = data.GetElementAsFloat(2);
                    _floatQueue.Enqueue(data.GetElementAsFloat(0));
                    _floatQueue.Enqueue(data.GetElementAsFloat(1));
                    _floatQueue.Enqueue(data.GetElementAsFloat(2));
                }
                break;

            case DataType.Vector4:
                lock (_floatQueue)
                {
                    vector4Data.x = data.GetElementAsFloat(0);
                    vector4Data.y = data.GetElementAsFloat(1);
                    vector4Data.z = data.GetElementAsFloat(2);
                    vector4Data.w = data.GetElementAsFloat(3);
                    _floatQueue.Enqueue(data.GetElementAsFloat(0));
                    _floatQueue.Enqueue(data.GetElementAsFloat(1));
                    _floatQueue.Enqueue(data.GetElementAsFloat(2));
                    _floatQueue.Enqueue(data.GetElementAsFloat(3));
                }
                break;

            case DataType.Vector2Int:
                lock (_intQueue)
                {
                    vector2IntData.x = data.GetElementAsInt(0);
                    vector2IntData.y = data.GetElementAsInt(1);
                    _intQueue.Enqueue(data.GetElementAsInt(0));
                    _intQueue.Enqueue(data.GetElementAsInt(1));
                }
                break;

            case DataType.Vector3Int:
                lock (_intQueue)
                {
                    vector3IntData.x = data.GetElementAsInt(0);
                    vector3IntData.y = data.GetElementAsInt(1);
                    _intQueue.Enqueue(data.GetElementAsInt(0));
                    _intQueue.Enqueue(data.GetElementAsInt(1));
                    _intQueue.Enqueue(data.GetElementAsInt(2));
                }
                break;
            }
        }