Esempio n. 1
0
        internal void Encode(OscPacketEncoder _encoder)
        {
            _encoder.Append(address);
            _encoder.Append(MakeTags());

            if (data == null)
            {
                return;
            }

            foreach (var d in data)
            {
                var type = d.GetType();

                if (type == typeof(int))
                {
                    _encoder.Append((int)d);
                }
                else if (type == typeof(float))
                {
                    _encoder.Append((float)d);
                }
                else if (type == typeof(string))
                {
                    _encoder.Append((string)d);
                }
                else if (type == typeof(bool))
                {
                }                                  // nothins
            }
        }
Esempio n. 2
0
        // makes sure that needed state has been defined
        void clientSetup()
        {
            if (_encoder == null)
            {
                _encoder = new OscPacketEncoder();
            }

            if (_socket != null)
            {
                return;
            }

            //Debug.Log("******************************* clientSetup");
            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            if (targetIP == "255.255.255.255")
            {
                _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
            }

            var dest = new IPEndPoint(IPAddress.Parse(targetIP), targetPort);

            _socket.Connect(dest);
        }