Ejemplo n.º 1
0
        // TODO: rewrite this
        public ClientRequestInfo FindServer()
        {
            ClientRequestInfo settings = new ClientRequestInfo();

            Console.WriteLine("Press 'Enter' to find a server.");
            Console.ReadLine();

            // settings.ip_address = GetServerIP();
            // settings.port_number = GetServerPort();

            return settings;
        }
Ejemplo n.º 2
0
        ///*If the server is found on the network, get entry for the password the user gave. */
        //private string GetPassword()
        //{
        //}
        internal void CheckServer(ClientRequestInfo settings)
        {
            int err = 0;

            // Check the IP address.
            Console.WriteLine("Checking " + settings.ip_address + " Server address...");
            if (Net.CheckAddress(settings.ip_address))
            {
                Console.WriteLine("Address Found.");
            }
            else
            {
                err++;
                Console.WriteLine("Failed to find address.");
            }

            //// Check if the port is open
            //Console.WriteLine("Checking to see if port " + settings.port_number.ToString() + " is open...");
            //using(System.Net.Sockets.TcpClient tcp = new System.Net.Sockets.TcpClient())
            //{
            //    try
            //    {
            //        tcp.Connect(settings.ip_address, settings.port_number);
            //        Console.WriteLine(settings.port_number.ToString() + " is open.");
            //    }
            //    catch (Exception)
            //    {
            //        err++;
            //        Console.WriteLine(settings.port_number.ToString() + " is not open.");
            //    }
            //}

            // TODO: Check if the password is correct.

            if (err == 0)
            {
                Console.WriteLine("Starting Connection to Server...");
            }
            else
            {
                // TODO: later we can just have the application close out
                Console.WriteLine("Connection to Server Failed. Shuting down.");
                Console.ReadLine();
                Environment.Exit(0);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Sends an actionable response to client with a formatted message.
 /// </summary>
 /// <param name="requestInfo"><see cref="ClientRequestInfo"/> instance containing the client request.</param>
 /// <param name="success">Flag that determines if this response to client request was a success.</param>
 /// <param name="status">Formatted status message to send with response.</param>
 /// <param name="args">Arguments of the formatted status message.</param>
 protected virtual void SendResponse(ClientRequestInfo requestInfo, bool success, string status, params object[] args)
 {
     SendResponseWithAttachment(requestInfo, success, null, status, args);
 }
Ejemplo n.º 4
0
 public void send_request(ClientRequestInfo ri) {
     object testEntryBeginAsObject = ri.get_slot(m_slotId);
     if (testEntryBeginAsObject != null) {
         int testEntryBegin = (int)testEntryBeginAsObject;
         TestServiceContext contextEntry = new TestServiceContext();
         contextEntry.TestEntry = testEntryBegin;
         ServiceContext context = new ServiceContext(1000,
                                                 m_codec.encode(contextEntry));
         ri.add_request_service_context(context, true);
     }
 }
Ejemplo n.º 5
0
 public void receive_exception(ClientRequestInfo ri) {
 }
Ejemplo n.º 6
0
 public void send_poll(ClientRequestInfo ri) {
 }
Ejemplo n.º 7
0
 public void receive_other(ClientRequestInfo ri)
 {
 }
Ejemplo n.º 8
0
 public void send_request(ClientRequestInfo ri) {            
     if (MustNonInterceptCall(ri)) {
         return;
     }
     m_invokedOnOutPath = true;
     TestServiceContext contextEntry = new TestServiceContext();
     contextEntry.TestEntry = m_contextEntryBegin;
     ServiceContext context = new ServiceContext(1000,
                                                 m_codec.encode(contextEntry));
     ri.add_request_service_context(context, true);
     try {
         TaggedComponent taggedComponentEnc = ri.get_effective_component(1000);
         omg.org.CORBA.TypeCode typeCode = 
             omg.org.CORBA.OrbServices.GetSingleton().create_tc_for_type(typeof(TestComponent));
         m_taggedComponent = m_codec.decode_value(taggedComponentEnc.component_data, typeCode);
     } catch (BAD_PARAM) {
         m_taggedComponent = null;
     }
 }
Ejemplo n.º 9
0
 public void send_poll(ClientRequestInfo ri) {
     // never called by IIOP.NET
 }
Ejemplo n.º 10
0
 // Reloads system settings from the database.
 private void ReloadSystemSettingsRequestHandler(ClientRequestInfo requestInfo)
 {
     m_sequenceOfEventsEngine.ReloadSystemSettings();
     SendResponse(requestInfo, true);
 }
 /// <inheritdoc />
 public virtual void send_poll(ClientRequestInfo ri)
 {
     //Nada a ser feito;
 }
 /// <inheritdoc />
 public virtual void receive_reply(ClientRequestInfo ri)
 {
     //Nada a ser feito;
 }
Ejemplo n.º 13
0
 public void receive_other(ClientRequestInfo ri) {
     if (MustNonInterceptCall(ri)) {
         return;
     }
     m_inPathResult = InPathResult.Other;
 }
Ejemplo n.º 14
0
 public void receive_exception(ClientRequestInfo ri) {
     if (MustNonInterceptCall(ri)) {
         return;
     }
     m_inPathResult = InPathResult.Exception;
 }
Ejemplo n.º 15
0
 public void receive_reply(ClientRequestInfo ri) {
     if (MustNonInterceptCall(ri)) {
         return;
     }
     m_inPathResult = InPathResult.Reply;
     try {
         ServiceContext context = ri.get_reply_service_context(1000);
         m_lastContextElement = (TestServiceContext)m_codec.decode(context.context_data);    
     } catch (BAD_PARAM) {
         m_lastContextElement = null; // not found
     }
 }
Ejemplo n.º 16
0
 private SynchRequest(ClientRequestInfo requestInfo)
 {
     this.info = requestInfo;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Sends an actionable response to client.
 /// </summary>
 /// <param name="requestInfo"><see cref="ClientRequestInfo"/> instance containing the client request.</param>
 /// <param name="success">Flag that determines if this response to client request was a success.</param>
 protected virtual void SendResponse(ClientRequestInfo requestInfo, bool success)
 {
     SendResponseWithAttachment(requestInfo, success, null, null);
 }
Ejemplo n.º 18
0
        static public ClientRequestInfo Decode(byte[] data)
        {
            var ps = new ClientRequestInfo();
            var i  = 0;

            var len = BitConverterBE.ToUInt16(data, i);

            i += 2;

            var magicBytes = data.Skip(i).Take(4).ToArray();

            if (magicBytes[0] != 0 || magicBytes[1] != 1 || magicBytes[2] != 3 || magicBytes[3] != 0)
            {
                return(null); // this shit aint tribes
            }
            i += 4;

            i += 3; // idk what this is

            while (true)
            {
                ps.Game1 += Encoding.ASCII.GetString(data, i, 1);
                i++;

                if (i >= data.Length)
                {
                    return(null); // no terminating nullbyte
                }

                if (data[i] == 0)
                {
                    i++;
                    break;
                }
            }

            while (true)
            {
                ps.Game2 += Encoding.ASCII.GetString(data, i, 1);
                i++;

                if (i >= data.Length)
                {
                    return(null); // no terminating nullbyte
                }

                if (data[i] == 0)
                {
                    i++;
                    break;
                }
            }

            while (true)
            {
                ps.Validate = ps.Validate.Concat(new byte[] { data[i] }).ToArray();
                i++;

                if (i >= data.Length)
                {
                    return(null); // no terminating nullbyte
                }

                if (data[i] == 0)
                {
                    i++;
                    break;
                }
            }

            while (true)
            {
                ps.Query += Encoding.ASCII.GetString(data, i, 1);
                i++;

                if (i >= data.Length)
                {
                    return(null); // no terminating nullbyte
                }

                if (data[i] == 0)
                {
                    i++;
                    break;
                }
            }

            return(ps);
        }
Ejemplo n.º 19
0
 public void receive_other(ClientRequestInfo ri) {
     m_inPathResult = InPathResult.Other;
     if (m_throwExceptionInPath != null) {
         throw m_throwExceptionInPath;
     }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// <see cref="omg.org.PortableInterceptor.ClientRequestInterceptor.send_request"></see>
 /// </summary>        
 public void send_request(ClientRequestInfo ri) {
     ClientRequestInfoImpl internalInfo = (ClientRequestInfoImpl)ri; // need access to connection information
     
     if ((internalInfo.ConnectionDesc.Connection.IsInitiatedLocal()) && // initiated in this appdomain
         (internalInfo.ConnectionDesc.ConnectionManager.SupportBiDir())) {
                                             
         GiopBidirectionalConnectionManager biDirConManager =
             (GiopBidirectionalConnectionManager)internalInfo.ConnectionDesc.ConnectionManager;
         
         ListenPoint[] listenPointsEntry = ConvertToListenPoints(biDirConManager.GetOwnListenPoints());
         BiDirIIOPServiceContext contextEntry = new BiDirIIOPServiceContext(listenPointsEntry);
         
         ServiceContext svcContext = new ServiceContext(BI_DIR_IIOP.ConstVal, 
                                                        m_codec.encode_value(contextEntry));                
         ri.add_request_service_context(svcContext, true);
         
         biDirConManager.SetupConnectionForBidirReception(internalInfo.ConnectionDesc);            
     }
     
 }
Ejemplo n.º 21
0
 public void receive_exception(ClientRequestInfo ri)
 {
 }
Ejemplo n.º 22
0
 /// <summary>
 /// <see cref="omg.org.PortableInterceptor.ClientRequestInterceptor.send_poll"></see>
 /// </summary>        
 public void send_poll(ClientRequestInfo ri) {
     // nothing to do
 }
Ejemplo n.º 23
0
 // Reloads system settings from the database
 private void ReloadSystemSettingsRequestHandler(ClientRequestInfo requestInfo)
 {
     m_extensibleDisturbanceAnalysisEngine.ReloadSystemSettings();
 }
Ejemplo n.º 24
0
 /// <summary>
 /// <see cref="omg.org.PortableInterceptor.ClientRequestInterceptor.receive_reply"></see>
 /// </summary>        
 public void receive_reply(ClientRequestInfo ri) {
     // nothing to do
 }
Ejemplo n.º 25
0
 public void receive_reply(ClientRequestInfo ri) {
     try {
         ServiceContext context = ri.get_reply_service_context(1000);
         m_lastContextElement = (TestServiceContext)m_codec.decode(context.context_data);    
     } catch (BAD_PARAM) {
         m_lastContextElement = null; // not found
     }
 }
Ejemplo n.º 26
0
 /// <summary>
 /// <see cref="omg.org.PortableInterceptor.ClientRequestInterceptor.receive_exception"></see>
 /// </summary>        
 public void receive_exception(ClientRequestInfo ri) {
     // nothing to do
 }
Ejemplo n.º 27
0
 public void receive_other(ClientRequestInfo ri) {
 }
Ejemplo n.º 28
0
 /// <summary>
 /// <see cref="omg.org.PortableInterceptor.ClientRequestInterceptor.receive_other"></see>
 /// </summary>        
 public void receive_other(ClientRequestInfo ri) {
     // nothing to do
 }
Ejemplo n.º 29
0
        private void ForceEventRequestHandler(ClientRequestInfo requestInfo)
        {
            if (requestInfo.Request.Arguments.ContainsHelpRequest)
            {
                StringBuilder helpMessage = new StringBuilder();

                helpMessage.Append("Forces an event to be processed by the file watcher on a set of files.");
                helpMessage.AppendLine();
                helpMessage.AppendLine();
                helpMessage.Append("   Usage:");
                helpMessage.AppendLine();
                helpMessage.Append("       ForceEvent <EventType> <File> [<File>...] [Options]");
                helpMessage.AppendLine();
                helpMessage.AppendLine();
                helpMessage.Append("   EventType:".PadRight(20));
                helpMessage.Append("Type of the event (Created, Changed, Deleted, Renamed)");
                helpMessage.AppendLine();
                helpMessage.Append("   File:".PadRight(20));
                helpMessage.Append("Name of the file to be processed (wildcards allowed)");
                helpMessage.AppendLine();
                helpMessage.AppendLine();
                helpMessage.Append("   Options:");
                helpMessage.AppendLine();
                helpMessage.Append("       -?".PadRight(20));
                helpMessage.Append("Displays this help message");

                DisplayResponseMessage(requestInfo, helpMessage.ToString());
            }
            else
            {
                FileEventType eventType;
                string        filePattern;
                string        orderedArg;

                if (!requestInfo.Request.Arguments.Exists("OrderedArg1"))
                {
                    SendResponse(requestInfo, false, "No event type was specified.");
                    return;
                }

                if (!Enum.TryParse(requestInfo.Request.Arguments["OrderedArg1"], true, out eventType))
                {
                    eventType = FileEventType.None;
                }

                for (int i = 2; i <= requestInfo.Request.Arguments.OrderedArgCount; i++)
                {
                    orderedArg  = string.Format("OrderedArg{0}", i);
                    filePattern = requestInfo.Request.Arguments[orderedArg];

                    if (!Path.IsPathRooted(filePattern))
                    {
                        filePattern = Path.Combine(m_fileWatcher.RootPathToWatch, filePattern);
                    }

                    foreach (string filePath in FilePath.GetFileList(filePattern))
                    {
                        m_fileWatcher.ProcessEvent(filePath, eventType);
                    }
                }

                SendResponse(requestInfo, true, "Command {0} successfully invoked.", requestInfo.Request.Command.QuoteWrap());
            }
        }
Ejemplo n.º 30
0
 public void send_poll(ClientRequestInfo ri)
 {
     // never called by IIOP.NET
 }
Ejemplo n.º 31
0
 private void RefreshMetaDataHandler(ClientRequestInfo requestInfo) => eDNAGrafanaController.eDNAGrafanaController.RefreshAllMetaData();
Ejemplo n.º 32
0
        // Attempts to restart the host service
        private void RestartServiceHandler(ClientRequestInfo requestInfo)
        {
            if (requestInfo.Request.Arguments.ContainsHelpRequest)
            {
                StringBuilder helpMessage = new StringBuilder();

                helpMessage.Append("Attempts to restart the host service.");
                helpMessage.AppendLine();
                helpMessage.AppendLine();
                helpMessage.Append("   Usage:");
                helpMessage.AppendLine();
                helpMessage.Append("       Restart [Options]");
                helpMessage.AppendLine();
                helpMessage.AppendLine();
                helpMessage.Append("   Options:");
                helpMessage.AppendLine();
                helpMessage.Append("       -?".PadRight(20));
                helpMessage.Append("Displays this help message");

                DisplayResponseMessage(requestInfo, helpMessage.ToString());
            }
            else
            {
                if (m_allowRemoteRestart)
                {
                    BroadcastMessage("Attempting to restart host service...");

                    try
                    {
                        ProcessStartInfo psi = new ProcessStartInfo(ConsoleApplicationName)
                        {
                            CreateNoWindow  = true,
                            WindowStyle     = ProcessWindowStyle.Hidden,
                            UseShellExecute = false,
                            Arguments       = ServiceName + " -restart"
                        };

                        using (Process shell = new Process())
                        {
                            shell.StartInfo = psi;
                            shell.Start();

                            if (!shell.WaitForExit(30000))
                            {
                                shell.Kill();
                            }
                        }

                        SendResponse(requestInfo, true);
                    }
                    catch (Exception ex)
                    {
                        SendResponse(requestInfo, false, "Failed to restart host service: {0}", ex.Message);
                        HandleException(ex);
                    }
                }
                else
                {
                    BroadcastMessage("Remote restart request denied, this is currently disallowed in the system configuration.", UpdateType.Warning);
                }
            }
        }
Ejemplo n.º 33
0
 // Reloads system settings from the database.
 private void ReloadSystemSettingsRequestHandler(ClientRequestInfo requestInfo)
 {
     m_fileWatcherEngine.ReloadSystemSettings();
     SendResponse(requestInfo, true);
 }
Ejemplo n.º 34
0
        // Sends remote entry for logging
        private void LogEventRequestHandler(ClientRequestInfo requestInfo)
        {
            if (requestInfo.Request.Arguments.ContainsHelpRequest)
            {
                StringBuilder helpMessage = new StringBuilder();

                helpMessage.Append("Logs remote entry to event log.");
                helpMessage.AppendLine();
                helpMessage.AppendLine();
                helpMessage.Append("   Usage:");
                helpMessage.AppendLine();
                helpMessage.Append("       LogEvent [Options]");
                helpMessage.AppendLine();
                helpMessage.AppendLine();
                helpMessage.Append("   Options:");
                helpMessage.AppendLine();
                helpMessage.Append("       -?".PadRight(20));
                helpMessage.Append("Displays this help message");
                helpMessage.AppendLine();
                helpMessage.Append("       -Message=\"Event Message\"".PadRight(20));
                helpMessage.Append("Specifies message for event log entry (required)");
                helpMessage.AppendLine();
                helpMessage.Append("       -Type=[Error|Warning|Information|...]".PadRight(20));
                helpMessage.Append("Specifies EventLogEntryType setting (optional)");
                helpMessage.AppendLine();
                helpMessage.Append("       -ID=0".PadRight(20));
                helpMessage.Append("Specifies application event log ID (optional)");
                helpMessage.AppendLine();

                DisplayResponseMessage(requestInfo, helpMessage.ToString());
            }
            else
            {
                if (requestInfo.Request.Arguments.Exists("Message"))
                {
                    try
                    {
                        string            message = requestInfo.Request.Arguments["Message"];
                        string            type, id;
                        EventLogEntryType entryType;
                        ushort            eventID;

                        if (!(requestInfo.Request.Arguments.TryGetValue("Type", out type) && Enum.TryParse(type, out entryType)))
                        {
                            entryType = EventLogEntryType.Information;
                        }

                        if (!(requestInfo.Request.Arguments.TryGetValue("ID", out id) && ushort.TryParse(id, out eventID)))
                        {
                            eventID = 0;
                        }

                        EventLog.WriteEntry(ServiceName, message, entryType, eventID);
                        SendResponse(requestInfo, true, "Successfully wrote event log entry.");
                    }
                    catch (Exception ex)
                    {
                        SendResponse(requestInfo, false, "Failed to write event log entry: {0}", ex.Message);
                    }
                }
                else
                {
                    SendResponse(requestInfo, false, "Failed to write event log entry: required \"message\" parameter was not specified.");
                }
            }
        }
Ejemplo n.º 35
0
 /// <summary>
 /// Displays a response message to client requestor.
 /// </summary>
 /// <param name="requestInfo"><see cref="ClientRequestInfo"/> instance containing the client request.</param>
 /// <param name="status">Formatted status message to send to client.</param>
 protected virtual void DisplayResponseMessage(ClientRequestInfo requestInfo, string status)
 {
     DisplayResponseMessage(requestInfo, "{0}", status);
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Sends an actionable response to client.
 /// </summary>
 /// <param name="requestInfo"><see cref="ClientRequestInfo"/> instance containing the client request.</param>
 /// <param name="success">Flag that determines if this response to client request was a success.</param>
 private void SendResponse(ClientRequestInfo requestInfo, bool success)
 {
     SendResponseWithAttachment(requestInfo, success, null, null);
 }
Ejemplo n.º 37
0
 public void receive_reply(ClientRequestInfo ri) {
     m_inPathResult = InPathResult.Reply;
     if (m_throwExceptionInPath != null) {
         throw m_throwExceptionInPath;
     }
 }
Ejemplo n.º 38
0
 public void send_poll(ClientRequestInfo ri)
 {
 }
Ejemplo n.º 39
0
 public void send_request(ClientRequestInfo ri) {
     m_invokedOnOutPath = true;
     if (m_throwExceptionOutPath != null) {
         throw m_throwExceptionOutPath;
     }
 }
Ejemplo n.º 40
0
 /// <summary>don't intercept calls for interception control service</summary>
 private bool MustNonInterceptCall(ClientRequestInfo ri) {
    return ri.operation.Equals("IsReceiveSvcContextCalled") ||
           ri.operation.Equals("IsReceiveRequestCalled") ||
           ri.operation.Equals("GetOutPathResult") ||                  
           ri.operation.Equals("ClearInterceptorHistory");
 }