Ejemplo n.º 1
0
        public override void Connect(int localPort)
        {
            if (_client != null)
            {
                Close();
            }

            try
            {
                _localEndPoint = OSCStandaloneManager.CreateLocalEndPoint(localPort);

                _client = OSCStandaloneManager.CreateClient(_localEndPoint);

                _controllerThreadAsync = new AsyncCallback(ControllerThread);
                _client.BeginReceive(_controllerThreadAsync, _client);

                _isRunning = true;
            }
            catch (SocketException e)
            {
                if (e.ErrorCode == 10048)
                {
                    Debug.LogErrorFormat(
                        "[OSCReceiver] Socket Error: Could not use port {0} because another application is listening on it.",
                        localPort);
                }
                else
                {
                    Debug.LogErrorFormat("[OSCReceiver] Socket Error: Error Code {0}.\n{1}", e.ErrorCode, e.Message);
                }

                Close();
            }
            catch (ArgumentOutOfRangeException)
            {
                Debug.LogErrorFormat("[OSCReceiver] Invalid port: {0}", localPort);

                Close();
            }
            catch (Exception e)
            {
                Debug.LogErrorFormat("[OSCReceiver] Error: {0}", e);

                Close();
            }
        }
Ejemplo n.º 2
0
        public override void Connect(int localPort, string remoteHost, int remotePort)
        {
            if (_client != null)
            {
                Close();
            }

            _localEndPoint  = OSCStandaloneManager.CreateLocalEndPoint(localPort);
            _remoteEndPoint = OSCStandaloneManager.CreateRemoteEndPoint(remoteHost, remotePort);

            try
            {
                _client = OSCStandaloneManager.CreateClient(_localEndPoint);
            }
            catch (SocketException e)
            {
                if (e.ErrorCode == 10048)
                {
                    Debug.LogErrorFormat(
                        "[OSCTransmitter] Socket Error: Could not use local port {0} because another application is listening on it.",
                        localPort);
                }
                else
                {
                    Debug.LogErrorFormat("[OSCTransmitter] Socket Error: Error Code {0}.\n{1}", e.ErrorCode, e.Message);
                }

                Close();
            }
            catch (ArgumentOutOfRangeException)
            {
                Debug.LogErrorFormat("[OSCTransmitter] Invalid port: {0}", localPort);

                Close();
            }
            catch (Exception e)
            {
                Debug.LogErrorFormat("[OSCTransmitter] Error: {0}", e);

                Close();
            }
        }