Exemple #1
0
        void serverConnection_DataReceived(object sender, DataReceivedEventArgs e)
        {
            if (bIsFirst) // First Receive, we assume password. This is lazy i know!
            {
                serverConnection.WriteLine(Program.Config.ServerPassword);
                bIsFirst = false;
                CalloutManager.AddCallout(this, new ServerCommandCallout("allitems"), TimeSpan.FromSeconds(30), false);
                Execute("lp");
                PublicMessage("7DTDManager Servercommands {0} online. See /help for commands", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
            }
            line += Convert.ToString(e.Data);

            if (!String.IsNullOrEmpty(line))
            {
                string[] newLines = line.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                if (!line.EndsWith("\r\n"))
                {
                    line = newLines[newLines.Length - 1];
                    newLines[newLines.Length - 1] = String.Empty;
                }
                else
                {
                    line = String.Empty;
                }
                foreach (var item in newLines)
                {
                    if (!String.IsNullOrEmpty(item))
                    {
                        linesToProcess.Enqueue(item);
                    }
                }
                //logger.Info("Stack: {0} Rest: {1}", linesToProcess.Count, line);
            }
            ProcessLines();
        }
Exemple #2
0
        protected override Task CloseAsync()
        {
            base.CloseAsync();

            CalloutManager.HideAllCallouts();
            _showCalloutDispatcherTimer.Stop();
            _showCalloutDispatcherTimer.Tick -= OnShowCalloutDispatcherTimerTick;

            return(Task.CompletedTask);
        }