예제 #1
0
        public void ParseInputLine(string line)
        {
            Console.WriteLine($"< '{line}'");

            line = line.Trim();

            if (line.StartsWith("notify") || line.StartsWith("channel"))
            {
                ReceivedEvcent(line);
                return;
            }

            if (CurrentCommand != null)
            {
                if (line.StartsWith("error"))
                {
                    Response = Response.Trim();

                    if (line.EndsWith("ok"))
                    {
                        CurrentCommand.Invoke(null, Response);
                    }
                    else
                    {
                        Console.WriteLine($"Command did not execute successfully (last line '{line}'). Leftover response: {Response}");
                        CommandException = new TeamspeakCommandException($"Command did not execute successfully (last line '{line}'). Leftover response: {Response}");
                        CurrentCommand.Invoke(CommandException, Response);
                    }

                    Response       = "";
                    CurrentCommand = null;
                    if (CommandCallbacks.Count > 0)
                    {
                        (string cmd, Action <Exception, string> callback) = CommandCallbacks.Dequeue();
                        DoSendCommand(cmd, callback);
                    }
                }
                else
                {
                    Response += $"{line}\n\r";
                }
            }
        }