コード例 #1
0
ファイル: Listener.cs プロジェクト: llenroc/CSRoot
 private void  SyncDataFromServer(IChannelServerToClient remoteObject)
 {
     try
     {
         m_Port            = remoteObject.GetServerPort();
         m_CallerDirectory = remoteObject.GetClientDirectory();
         m_CallerExe       = remoteObject.GetCallingExe();
         Trace.WriteLine("data was queried successfully from server");
     }
     catch (Exception ex)
     {
         //we can recover from this error
         s_Logger.LogInfo("Could not retriev data from Sniper server" + ex.ToString());
     }
 }
コード例 #2
0
ファイル: Listener.cs プロジェクト: llenroc/CSRoot
        public void Listen()
        {
            try
            {
                if (s_AlreadyHooked == true)
                {
                    return;
                }
                s_AlreadyHooked = true;
                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

                //Connect to server at port 60200 and get the port number at which to open service
                TcpClientChannel clientChannel = new TcpClientChannel("HookedClient", null);
                ChannelServices.RegisterChannel(clientChannel, true);
                Trace.WriteLine("MissionControl::injectHook going to connect to server");
                IChannelServerToClient remoteObject = (IChannelServerToClient)Activator.GetObject(
                    typeof(IChannelServerToClient), "tcp://localhost:60300/CSRoot.rem");
                if (remoteObject == null)
                {
                    s_Logger.LogError("Connection to CSRoot server could not be established");
                }

                SyncDataFromServer(remoteObject);

                s_Logger.LogInfo("The port sent from server is " + m_Port.ToString(CultureInfo.CurrentCulture));

                //now start thread to listen to client
                object param = (object)m_Port;
                Thread clientListenerThread = new Thread(new ParameterizedThreadStart(StartClientServer));
                clientListenerThread.Start(param);

                s_Logger.LogInfo("Server has been started at client side");
            }
            catch (Exception e)
            {
                s_Logger.LogInfo("Exception at Listener:Listen");
            }
        }