private string TestTran(string input, AHostCommand HC)
        {
            MessageResponse retMsg;

            Message.Message msg = new Message.Message(input);

            string trailingChars = "";

            if (ExpectTrailers())
            {
                trailingChars = msg.GetTrailers();
            }

            HC.AcceptMessage(msg);

            if (HC.XMLParseResult != ErrorCodes.ER_00_NO_ERROR)
            {
                retMsg = new MessageResponse();
                retMsg.AddElement(HC.XMLParseResult);
            }
            else
            {
                retMsg = HC.ConstructResponse();
            }

            retMsg.AddElement(trailingChars);

            HC.Terminate();
            HC = null;
            return(retMsg.MessageData);
        }
Example #2
0
        private string TestMessage(string message, AHostCommand command)
        {
            var msg = new StreamMessage(message);

            command.AcceptMessage(msg);
            if (command.XmlParseResult != ErrorCodes.ER_00_NO_ERROR)
            {
                return(command.XmlParseResult);
            }

            var rsp = command.ConstructResponse();

            return(rsp.GetBytes().GetString());
        }
Example #3
0
        private void TestMessageWithIo(string message, AHostCommand command, out string rsp, out string rspAfterIo)
        {
            var msg = new StreamMessage(message);

            command.AcceptMessage(msg);
            if (command.XmlParseResult != ErrorCodes.ER_00_NO_ERROR)
            {
                rsp        = command.XmlParseResult;
                rspAfterIo = string.Empty;
                return;
            }

            rsp = command.ConstructResponse().Message;

            rspAfterIo = command.ConstructResponseAfterIo().Message;
        }
Example #4
0
        private void WCMessageArrived(TCP.WorkerClient sender, byte[] b, int len)
        {
            TCPEventArgs e = new TCPEventArgs();

            e.RemoteClient = sender.ClientIP();

            e.Data = new byte[len];

            DataArrived(this, e);

            Array.Copy(b, 0, e.Data, 0, len);

            Message.Message msg = new Message.Message(b);

            Logger.MajorVerbose("Client: " + sender.ClientIP() + System.Environment.NewLine + "Request: " + msg.MessageData);
            try
            {
                Logger.MajorDebug("Parsing header and code of message " + msg.MessageData + "...");
                string messageHeader = msg.GetSubstring(HeaderLength);

                msg.AdvanceIndex(HeaderLength);

                string commandCode = msg.GetSubstring(2);

                msg.AdvanceIndex(2);

                CommandCalled(this, commandCode);

                CommandClass CC = CE.GetLoadedCommand(commandCode);

                if (CC == null)
                {
                    Logger.MajorError("No implementor for " + commandCode + "." + System.Environment.NewLine + "Disconnecting client.");
                    sender.TermClient();
                }
                else
                {
                    Logger.MajorDebug("Found implementor " + CC.DeclaringType.FullName + ", instantiating...");
                    AHostCommand o = (AHostCommand)Activator.CreateInstance(CC.DeclaringType);
                    o = (AHostCommand)Activator.CreateInstance(CC.DeclaringType);

                    Message.MessageResponse retMsg;
                    Message.MessageResponse retMsgAfterIO;

                    try
                    {
                        string trailingChars = "";
                        if (ExpectTrailers)
                        {
                            trailingChars = msg.GetTrailers();
                        }

                        if ((CheckLMKParity == false) || (Cryptography.LMK.LMKStorage.CheckLMKStorage()))
                        {
                            //Logger.MinorInfo("=== [" + commandCode + "], starts " + Utility.getTimeMMHHSSmmmm + " =======");

                            Logger.MajorDebug("Calling AcceptMessage()...");
                            o.AcceptMessage(msg);

                            Logger.MinorVerbose(o.DumpFields());
                        }
                    }
                    catch (Exception ex)
                    { }
                }
            }
            catch (Exception ex)
            {
            }
        }