//网页上发送来的指令,都会被传到Notify函数中, 如需对网页上执行的命令进行限制, 可在Notify函数里手工加入判断限制代码。 #region IObserver Members public void Notify(object sender, string text) { if (InvokeRequired) { Invoke(new NotifyDelegate(Notify), sender, text); return; } richTextBox1.SelectionColor = Color.LimeGreen; richTextBox1.SelectionFont = new Font("宋体", 9); richTextBox1.AppendText("\r\n" + text); richTextBox1.AppendText("\r\n"); if (ec.m_ConnectionState == StateClass.ConnectionState.Logined) { remotableObject = (MyRemotableObject)sender; if (text.ToUpper().Trim().StartsWith("RT")) { //此构造函数可以提取团队中的姓名等特殊数据 RTWithNMAndPrice(text); } else if (text.ToUpper().Trim().StartsWith("AV")) { GetFlights(text); } } else { remotableObject = (MyRemotableObject)sender; remotableObject.ResultString = "服务器ETERM未登陆 或 执行了RT以外的指令\r\rCommand:" + text; remotableObject.Set(); } }
private void CmdCB(object sender, CmdResult result) { if (InvokeRequired) { Invoke(new EtermConnection.CmdResultCB(CmdCB), sender, result); return; } richTextBox1.SelectionColor = Color.LimeGreen; richTextBox1.SelectionFont = new Font("宋体", 9); richTextBox1.AppendText("\r\n" + result.Data); this.richTextBox1.Select(this.richTextBox1.TextLength, 0); this.richTextBox1.ScrollToCaret(); richTextBox1.AppendText("\r\n" + (char)9632); if (remotableObject != null) { remotableObject.ResultString = result.Data; remotableObject.Set(); } }