/// <summary> /// 接收 从Scratch到仿真接收的消息 /// </summary> /// <param name="msg"></param> protected void OnMessage(byte[] msg) { var protocol = ProtocolFactory.Generate(ProtocolOutput.ScratchToExplore, msg, 0, msg.Length); if (protocol == null) { DebugUtility.LogError(LoggerTags.Online, "OnMessage Failed : The protocol is null."); return; } DebugUtility.Log(LoggerTags.Online, "Recv message : {0}", protocol.ToString()); mDispatcher.OnMessage(protocol); }
/// <summary> /// 来自于控制端的转发,一般是控制Robot怎么执行指令 /// </summary> /// <param name="e"></param> protected override void OnMessage(MessageEventArgs e) { base.OnMessage(e); DebugUtility.Log(LoggerTags.Online, "【Server】 Status : {0}, OnMessage.", this.ConnectionState); var dispatcher = labDispatcher; if (dispatcher == null) { return; } var protocol = ProtocolFactory.Generate(ProtocolOutput.ScratchToExplore, e.RawData, 0, e.RawData.Length); if (protocol == null) { DebugUtility.LogError(LoggerTags.Online, "【Server】OnMessage Failed : The protocol is null."); return; } DebugUtility.Log(LoggerTags.Online, "【Server】 recv message"); protocol.host = forwardPath; dispatcher.OnMessage(protocol); }