void ConnectThread()
        {
            try
            {
                //Console.WriteLine("Logging in with username " + ConnectionData.User + "...");
                AuthService authService = new AuthService(ConnectionData.Region.LoginQueueURL, ConnectionData.Proxy.LoginQueueProxy);
                // Get an Auth token (Dumb, assumes no queueing, blocks)
                AuthResponse = authService.Authenticate(ConnectionData.User, ConnectionData.Password);
                //if (AuthResponse.Status == "LOGIN")
                //Console.WriteLine("Login successful.");
                //else if (AuthResponse.Status == "QUEUE")
                //Console.WriteLine("Queue to login to server.");
            }
            catch (WebException exception)
            {
                ConnectCallback(new RPCConnectResult(exception));
                return;
            }

            // Initialise our RTMPS connection
            RPCNetConnection       = new NetConnection();
            RPCNetConnection.Proxy = ConnectionData.Proxy.RTMPProxy;

            // We should use AMF3 to behave as closely to the client as possible.
            RPCNetConnection.ObjectEncoding = ObjectEncoding.AMF3;

            // Setup handlers for different network events.
            RPCNetConnection.OnConnect    += new ConnectHandler(NetConnectionOnConnect);
            RPCNetConnection.OnDisconnect += new DisconnectHandler(NetConnectionOnDisconnect);
            RPCNetConnection.NetStatus    += new NetStatusHandler(NetConnectionNetStatus);

            // Connect to the RTMPS server
            RPCNetConnection.Connect(ConnectionData.Region.RPCURL);
        }
        void ConnectThread()
        {
            try
            {
                AuthService authService = new AuthService(ConnectionData.Region.LoginQueueURL, ConnectionData.Proxy.LoginQueueProxy);
                // Get an Auth token (Dumb, assumes no queueing, blocks)
                AuthResponse = authService.Authenticate(ConnectionData.User, ConnectionData.Password);
            }
            catch (WebException exception)
            {
                ConnectCallback(new RPCConnectResult(exception));
                return;
            }

            // Initialise our RTMPS connection
            RPCNetConnection       = new NetConnection();
            RPCNetConnection.Proxy = ConnectionData.Proxy.RTMPProxy;

            // We should use AMF3 to behave as closely to the client as possible.
            RPCNetConnection.ObjectEncoding = ObjectEncoding.AMF3;

            // Setup handlers for different network events.
            RPCNetConnection.OnConnect    += new ConnectHandler(NetConnectionOnConnect);
            RPCNetConnection.OnDisconnect += new DisconnectHandler(NetConnectionOnDisconnect);
            RPCNetConnection.NetStatus    += new NetStatusHandler(NetConnectionNetStatus);

            try
            {
                // Connect to the RTMPS server
                RPCNetConnection.Connect(ConnectionData.Region.RPCURL);
            }
            catch (IOException)
            {
                if (DisconnectCallback != null)
                {
                    DisconnectCallback();
                }
            }
            catch (SocketException)
            {
                if (DisconnectCallback != null)
                {
                    DisconnectCallback();
                }
            }
        }
        void ConnectThread()
        {
            try
            {
                AuthService authService = new AuthService(ConnectionData.Region.LoginQueueURL, ConnectionData.Proxy.LoginQueueProxy);
                // Get an Auth token (Dumb, assumes no queueing, blocks)
                AuthResponse = authService.Authenticate(ConnectionData.User, ConnectionData.Password);
            }
            catch (WebException exception)
            {
                ConnectCallback(new RPCConnectResult(exception));
                return;
            }

            // Initialise our RTMPS connection
            RPCNetConnection = new NetConnection();
            RPCNetConnection.Proxy = ConnectionData.Proxy.RTMPProxy;

            // We should use AMF3 to behave as closely to the client as possible.
            RPCNetConnection.ObjectEncoding = ObjectEncoding.AMF3;

            // Setup handlers for different network events.
            RPCNetConnection.OnConnect += new ConnectHandler(NetConnectionOnConnect);
            RPCNetConnection.OnDisconnect += new DisconnectHandler(NetConnectionOnDisconnect);
            RPCNetConnection.NetStatus += new NetStatusHandler(NetConnectionNetStatus);

            // Connect to the RTMPS server
            RPCNetConnection.Connect(ConnectionData.Region.RPCURL);
        }