Exemplo n.º 1
0
 /// <summary>
 ///     Closes the connection with the server
 /// </summary>
 public void Disconnect()
 {
     if (m_Remote != null)
     {
         m_Remote  = null;
         Connected = false;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///     Tries to connect to the BoxServer
        /// </summary>
        /// <param name="ProcessErrors">Specifies whether to process errors and display them to the user</param>
        /// <returns>True if succesful</returns>
        public bool Connect(bool ProcessErrors)
        {
            try
            {
                var ConnectionString = string.Format(
                    "tcp://{0}:{1}/BoxRemote",
                    Pandora.Profile.Server.Address,
                    Pandora.Profile.Server.Port);

                m_Remote = Activator.GetObject(typeof(BoxRemote), ConnectionString) as BoxRemote;

                // Perform Login
                BoxMessage msg = new LoginMessage();

                msg.Username = Pandora.Profile.Server.Username;
                msg.Password = Pandora.Profile.Server.Password;
                var    data    = msg.Compress();
                string outType = null;

                var result = m_Remote.PerformRemoteRequest(msg.GetType().FullName, data, out outType);

                if (result == null)
                {
                    MessageBox.Show(Pandora.Localization.TextProvider["Errors.ServerError"]);
                    Connected = false;
                    return(false);
                }

                var t = Type.GetType(outType);

                var outcome = BoxMessage.Decompress(result, t);

                if (ProcessErrors)
                {
                    if (!CheckErrors(outcome))
                    {
                        Connected = false;
                        return(false);
                    }
                }

                if (outcome is LoginSuccess)
                {
                    Connected = true;
                    return(true);
                }
                Connected = false;
                return(false);
            }
            catch (Exception err)
            {
                Pandora.Log.WriteError(err, "Connection failed to box server");
                Connected = false;
            }

            return(false);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Closes the connection with the server
 /// </summary>
 public void Disconnect()
 {
     if (m_Remote != null)
     {
         m_Remote = null;
         Connected = false;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Tries to connect to the BoxServer
        /// </summary>
        /// <param name="ProcessErrors">Specifies whether to process errors and display them to the user</param>
        /// <returns>True if succesful</returns>
        public bool Connect(bool ProcessErrors)
        {
            try
            {
                string ConnectionString = string.Format("tcp://{0}:{1}/BoxRemote", Pandora.Profile.Server.Address, Pandora.Profile.Server.Port);

                m_Remote = Activator.GetObject(typeof(BoxRemote), ConnectionString) as BoxRemote;

                // Perform Login
                BoxMessage msg = new LoginMessage();

                msg.Username = Pandora.Profile.Server.Username;
                msg.Password = Pandora.Profile.Server.Password;
                byte[] data = msg.Compress();
                string outType = null;

                byte[] result = m_Remote.PerformRemoteRequest(msg.GetType().FullName, data, out outType);

                if (result == null)
                {
                    MessageBox.Show(Pandora.Localization.TextProvider["Errors.ServerError"]);
                    Connected = false;
                    return false;
                }

                Type t = Type.GetType(outType);

                BoxMessage outcome = BoxMessage.Decompress(result, t);

                if (ProcessErrors)
                {
                    if (!CheckErrors(outcome))
                    {
                        Connected = false;
                        return false;
                    }
                }

                if (outcome is LoginSuccess)
                {
                    Connected = true;
                    return true;
                }
                else
                {
                    Connected = false;
                    return false;
                }
            }
            catch (Exception err)
            {
                Pandora.Log.WriteError(err, "Connection failed to box server");
                Connected = false;
            }

            return false;
        }