/// <summary> /// Marks a command as completed and stores the server response. /// </summary> /// <param name="rdata"> /// The <see cref="ZIMapProtocol.ReceiveData"/> value returned from /// <see cref="ZIMapProtocol.Receive"/> /// </param> /// <returns> /// A <see cref="System.Boolean"/> /// </returns> public bool Completed(ZIMapProtocol.ReceiveData rdata) { if(state != CommandState.Running) { RaiseError(ZIMapException.Error.CommandState, state); return false; } if(tag != rdata.Tag) { RaiseError(ZIMapException.Error.InvalidArgument, "Unexpected tag"); return false; } data = rdata; state = (data.State == ZIMapProtocol.ReceiveState.Ready) ? CommandState.Completed : CommandState.Failed; MonitorDebug( "Completed: Tag: {0:x} Status: {1} ({2})", tag, data.Status, state); #if DEBUG if(MonitorLevel <= ZIMapConnection.Monitor.Debug) // expensive ... foreach(string line in data.ToString().Split("\n".ToCharArray())) MonitorDebug(" {0}", line); #endif ZIMapConnection.Callback.Result(factory.Connection, this); return true; }
public bool Completed(ZIMapProtocol.ReceiveData rdata) { if(GetCommands() == null) return false; // parent closed foreach(ZIMapCommand cmd in commands) { if(cmd.Tag != rdata.Tag) continue; if(cmd is ZIMapCommand.Login && rdata.Succeeded) username = ((ZIMapCommand.Login)cmd).User; return cmd.Completed(rdata); } return false; }