public override ICommand Execute(WSCommandTypeBase command, ExecuteCommandContext context) { SetCommandParserRequest cmd = new SetCommandParserRequest(command); SetCommandParserResponse response = new SetCommandParserResponse(); response.IsSuccess = false; if (context != null && context.CommandSession != null) { if (Parsers.ContainsKey(cmd.Type)) { context.CommandSession.CommandParser = Parsers[cmd.Type]; response.IsSuccess = true; } else { response.Message = "未知的命令格式"; } } else { response.Message = "内部错误,会话为空"; } return(response); }
public override ICommand Parse(WSCommandTypeBase command) { SetCommandParserResponse cmd = new SetCommandParserResponse(); cmd.LoadCommand(command); return(cmd); }
//在子类中实现此方法,用于插入触发Connected事件之前的特殊处理 protected virtual bool OnBeforeConnected() { bool isSuccess = false; Debug.WriteLine("Client Socket Status:" + Session.Session.SessionID + " " + Session.Session.ClientSocket.Connected.ToString()); CommandItem <WSCommandTypeBase> response = Session.SendCommandSync(new SetCommandParserRequest(SessionCommandParser.ParserID), RequestTimeout); if (response != null && response.CommandResponse != null) { SetCommandParserResponse cmdParserResponse = new SetCommandParserResponse(response.CommandResponse); if (cmdParserResponse.IsSuccess) { isSuccess = true; } } return(isSuccess); // return true; }