Esempio n. 1
0
        public static TransferMessage ProcessMessage(string Address, int Port, TransferMessage msg)
        {
            TransferMessage transferMessage;
            TransferMessage transferMessage1 = null;

            byte[] numArray = msg.Compress();
            string str      = null;
            string str1     = string.Format("tcp://{0}:{1}/RemoteMessaging", Address, Port);

            try
            {
                TransferConnection.m_Remote = Activator.GetObject(typeof(RemoteMessaging), str1) as RemoteMessaging;
            }
            catch
            {
                MessageBox.Show(string.Format("Failed to connect to remote server {0} : {1}", Address, Port));
                transferMessage = null;
                return(transferMessage);
            }
            try
            {
                byte[] numArray1 = TransferConnection.m_Remote.PerformRemoteRequest(msg.GetType().FullName, numArray, out str);
                if (numArray1 != null)
                {
                    Type type = Type.GetType(str);
                    if (type == null)
                    {
                        Assembly assembly = Assembly.GetAssembly(typeof(TransferMessage));
                        if (assembly != null)
                        {
                            type = assembly.GetType(str);
                        }
                    }
                    transferMessage1 = TransferMessage.Decompress(numArray1, type);
                    if (TransferConnection.HasErrors(transferMessage1, type, str))
                    {
                        transferMessage1 = null;
                    }
                }
                else
                {
                    MessageBox.Show(string.Concat("No Data Received from Remote Server for ", msg.GetType().FullName));
                    transferMessage = null;
                    return(transferMessage);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                transferMessage1 = null;
            }
            return(transferMessage1);
        }
        public static TransferMessage ProcessMessage(string Address, int Port, TransferMessage msg)
        {
            byte[] data1      = msg.Compress();
            string answerType = (string)null;
            string url        = string.Format("tcp://{0}:{1}/RemoteMessaging", (object)Address, (object)Port);

            try
            {
                TransferConnection.m_Remote = Activator.GetObject(typeof(RemoteMessaging), url) as RemoteMessaging;
            }
            catch
            {
                int num = (int)MessageBox.Show(string.Format("Failed to connect to remote server {0} : {1}", (object)Address, (object)Port));
                return((TransferMessage)null);
            }
            TransferMessage msg1;

            try
            {
                byte[] data2 = TransferConnection.m_Remote.PerformRemoteRequest(msg.GetType().FullName, data1, out answerType);
                if (data2 == null)
                {
                    int num = (int)MessageBox.Show("No Data Received from Remote Server for " + msg.GetType().FullName);
                    return((TransferMessage)null);
                }
                Type type = Type.GetType(answerType);
                if (type == null)
                {
                    Assembly assembly = Assembly.GetAssembly(typeof(TransferMessage));
                    if (assembly != null)
                    {
                        type = assembly.GetType(answerType);
                    }
                }
                msg1 = TransferMessage.Decompress(data2, type);
                if (TransferConnection.HasErrors(msg1, type, answerType))
                {
                    msg1 = (TransferMessage)null;
                }
            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show(ex.Message);
                msg1 = (TransferMessage)null;
            }
            return(msg1);
        }