public virtual void SendReplyCommand(ICommand command, Guid requestGuid)
        {
            if (command == null)
            {
                return;
            }
            WSCommandTypeBase wsCommand = CommandParser.Create();

            command.ToCommand(wsCommand);
            wsCommand.RequestID = requestGuid;

            Session.SendMessage(CommandParser.ToBinary(wsCommand), CommandParser.TransferEncoder);
        }
        public virtual CommandItem <WSCommandTypeBase> SendCommandSync(ICommand command, TimeSpan timeout)
        {
            if (command == null)
            {
                return(null);
            }
            WSCommandTypeBase wsCommand = CommandParser.Create();

            command.ToCommand(wsCommand);

            wsCommand.RequestID     = Guid.NewGuid();
            Session.LastRequestTime = DateTime.Now;

            CommandItem <WSCommandTypeBase> ci = new CommandItem <WSCommandTypeBase>()
            {
                CommandRequest   = wsCommand,
                CommandResponse  = null,
                RetryCount       = 0,
                ResponseCallback = null,
                RequestTime      = DateTime.Now,
                IsSync           = true,
                Wait             = new System.Threading.AutoResetEvent(false)
            };

            lock (SyncLocker)
            {
                Commands.Add(ci);
            }

            logger.Trace("发送命令:{0}", wsCommand.CommandName);
            bool isSended = Session.SendMessage(CommandParser.ToBinary(wsCommand), CommandParser.TransferEncoder);

            if (!isSended)
            {
                return(ci);
            }

            ci.Wait.WaitOne(timeout);

            return(ci);
        }
        public virtual void SendCommand(ICommand command, CommandResponse callback)
        {
            if (command == null)
            {
                return;
            }
            WSCommandTypeBase wsCommand = CommandParser.Create();

            command.ToCommand(wsCommand);
            wsCommand.RequestID     = Guid.NewGuid();
            Session.LastRequestTime = DateTime.Now;
            lock (SyncLocker)
            {
                Commands.Add(new CommandItem <WSCommandTypeBase>()
                {
                    CommandRequest = wsCommand, CommandResponse = null, RetryCount = 0, ResponseCallback = callback, RequestTime = DateTime.Now, IsSync = false
                });
            }
            logger.Trace("发送命令:{0}", wsCommand.CommandName);
            Session.SendMessage(CommandParser.ToBinary(wsCommand), CommandParser.TransferEncoder);
        }