public BaseCommand[] GetCommand() { BaseCommand[] commandsQueue; lock (commandsBuffer) { commandsQueue = new BaseCommand[commandsBuffer.Count]; commandsBuffer.CopyTo(commandsQueue); commandsBuffer.Clear(); } return commandsQueue; }
/// <summary> /// Sends command to server and returns result. /// </summary> /// <param name="value">Instance of BaseCommand.</param> /// <returns>bool</returns> public bool SendCommand(BaseCommand commandObject) { try { string stringToSend = commandObject.Serialize(); sb.Append((char) commandObject.ID); sb.Append((char) stringToSend.Length); sb.Append(stringToSend); SendData(sb.ToString()); sb.Clear(); countOfSended++; return true; } catch (Exception ex) { ErrorLog.ReportError(ex.Message); return false; } }