예제 #1
0
        void socketSetup()
        {
            if (_socket != null)
            {
                return;
            }

            _dispatcher = new OscMessageDispatcher();
            _socket     = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            // On some platforms, it's not possible to cancel Receive() by
            // just calling Close() -- it'll block the thread forever!
            // Therefore, we heve to set timeout to break ServerLoop.
            _socket.ReceiveTimeout = 100;

            _socket.Bind(new IPEndPoint(IPAddress.Any, targetPort));

            _thread = new Thread(ServerLoop);
            _thread.Start();

#if OSC_SERVER_LIST
            _servers.Add(this);
#endif
            Debug.Log("********************** OscServer.socketSetup() Socket state: " + (_socket == null));
        }
예제 #2
0
        public OscServer(int listenPort, string multicast = null)
        {
            _dispatcher = new OscMessageDispatcher();
            _socket     = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            // On some platforms, it's not possible to cancel Receive() by
            // just calling Close() -- it'll block the thread forever!
            // Therefore, we heve to set timeout to break ServerLoop.
            _socket.ReceiveTimeout = 100;

            _socket.Bind(new IPEndPoint(IPAddress.Any, listenPort));

            if (!string.IsNullOrEmpty(multicast))
            {
                _socket.SetSocketOption(
                    SocketOptionLevel.IP,
                    SocketOptionName.AddMembership,
                    new MulticastOption(IPAddress.Parse(multicast), IPAddress.Any)
                    );
            }

            _thread = new Thread(ServerLoop);
            _thread.Start();

            #if OSC_SERVER_LIST
            _servers.Add(this);
            #endif
        }
예제 #3
0
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;

            if (!disposing)
            {
                return;
            }
            if (_socket != null)
            {
                _socket.Close();
                _socket = null;
            }

            if (_thread != null)
            {
                _thread.Join();
                _thread = null;
            }

            MessageDispatcher = null;
        }
        public OscServer(int listenPort)
        {
            _dispatcher = new OscMessageDispatcher();
            _socket     = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            // On some platforms, it's not possible to cancel Receive() by
            // just calling Close() -- it'll block the thread forever!
            // Therefore, we heve to set timeout to break ServerLoop.
            _socket.ReceiveTimeout = 100;

            _socket.Bind(new IPEndPoint(IPAddress.Any, listenPort));

            _thread = new Thread(ServerLoop);
            _thread.Start();

            #if OSC_SERVER_LIST
            _servers.Add(this);
            #endif
        }
 public OscPacketParser(OscMessageDispatcher dispatcher)
 {
     _dispatcher = dispatcher;
 }