コード例 #1
0
        public void TestStatus()
        {
            string status = @"calvin276 status:
Current target: BlackMirror11
Current administrating system: none
Proxy level: 6
Current proxy address: kenguru2157@sydney";

            var statusResponse = StatusInstruction.Parse(status);

            Assert.NotNull(status, "Parsed not successfully");

            Assert.AreEqual("calvin276", statusResponse.Login, "Login");
            Assert.AreEqual("BlackMirror11", statusResponse.Target, "Target");
            Assert.AreEqual("none", statusResponse.AdminSystem, "Host");
            Assert.AreEqual(6, statusResponse.Proxy, "Proxy");
            Assert.AreEqual("kenguru2157@sydney", statusResponse.VisibleAs, "VisibleAs");
        }
コード例 #2
0
        protected override CommandResult ProcessXmppMessage(string message)
        {
            var commandResult = StatusInstruction.Parse(message);

            if (commandResult == null)
            {
                return(CreateError($"{CmdName} command resulted in error. Couldn't parse result\n {message}"));
            }

            if (!string.IsNullOrEmpty(commandResult.Error))
            {
                return(CreateError($"{CmdName} command resulted in error. {commandResult.Error}"));
            }


            var result = CreateOutput(new TextOutput(Verbosity, message), CommandState.Finished);

            result.UpdatedNetStatus = commandResult;
            return(result);
        }
コード例 #3
0
ファイル: XMPPLocal.cs プロジェクト: Krivda/gUmMY
        public void SendMessage(string message)
        {
            if (message.StartsWith("target"))
            {
                if (message.Split(' ').Length > 1)
                {
                    _target = message.Split(' ')[1];

                    string netPath = $"Server//Data//{_target}.xml";

                    _network = Serializer.DeserializeNet(netPath);
                }

                EmulateResponse("ok");
                //404 target system:2739100 not found
            }
            else if (message.StartsWith("status"))
            {
                EmulateResponse(StatusInstruction.Assemble($"{_user}@{_domain}",
                                                           string.IsNullOrEmpty(_target)?"none":_target,
                                                           _admSystem,
                                                           _proxyLevel,
                                                           _visibleAs));
            }
            else if (message.StartsWith("info"))
            {
                string codeStr = message.Replace("info #", "");
                long   softCode;

                string incorrectProgMessage = @"--------------------
incorrect program #{0}
END----------------";

                if (!long.TryParse(codeStr, out softCode))
                {
                    EmulateResponse(string.Format(incorrectProgMessage, codeStr));
                }
                else
                {
                    Structure.Software libSoft;
                    if (!_softwareLib.All.TryGetValue(softCode, out libSoft))
                    {
                        EmulateResponse(string.Format(incorrectProgMessage, codeStr));
                        return;
                    }
                    //soft found
                    EmulateResponse(InfoInstruction.Assemble(libSoft));
                }
            }
            else if (message.StartsWith("look"))
            {
                //todo: check errors

                string nodeName = message.Replace("look ", "");

                Node node;
                if (_network == null)
                {
                    EmulateResponse("network not found");
                }

                if (!_network.Nodes.TryGetValue(nodeName, out node))
                {
                    EmulateResponse($@"--------------------
{_network.Name} / {nodeName}: not available

END----------------");
                }
                else
                {
                    string response = LookInstruction.AssembleAccessible(_network.Name, node);
                    EmulateResponse(response);
                }
            }
            else if (message.StartsWith("#"))
            {
                EmulateResponse("Not implemented");
            }
            else
            {
                EmulateResponse("command no found");
            }
        }