public static IList BuildResponse(Hashtable removeResult, int commandVersion, long requestId, IList _serializedResponse, int commandID, long requestID, Caching.Cache cache, ClientManager clientManager) { Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.Cache = cache; //long requestId = Convert.ToInt64(RequestId); switch (commandVersion) { case 0: //Versions earlier than NCache 4.1 because all of them expect responses as one chunck { Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse bulkRemoveResponse = new Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse(); response.requestId = requestId; response.commandID = commandID; bulkRemoveResponse.keyValuePackage = Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysValues(removeResult, bulkRemoveResponse.keyValuePackage); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.REMOVE_BULK; response.bulkRemove = bulkRemoveResponse; _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response, Common.Protobuf.Response.Type.REMOVE_BULK)); } break; case 1: //Verion 4.1 or later { IList keyValuesPackageChuncks = Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysValues(removeResult); int sequenceId = 1; Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse bulkRemoveResponse = new Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse(); if (clientManager.ClientVersion >= 5000) { bulkRemoveResponse.numberOfChuncks = keyValuesPackageChuncks.Count; Common.Util.ResponseHelper.SetResponse(bulkRemoveResponse, requestID, commandID); foreach (Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse package in keyValuesPackageChuncks) { bulkRemoveResponse.sequenceId = sequenceId++; bulkRemoveResponse.keyValuePackage = package; _serializedResponse.Add(Common.Util.ResponseHelper.SerializeResponse(bulkRemoveResponse, Common.Protobuf.Response.Type.REMOVE_BULK)); } } else { response.numberOfChuncks = keyValuesPackageChuncks.Count; Common.Util.ResponseHelper.SetResponse(response, requestID, commandID, Common.Protobuf.Response.Type.REMOVE_BULK); foreach (Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse package in keyValuesPackageChuncks) { response.sequenceId = sequenceId++; bulkRemoveResponse.keyValuePackage = package; response.bulkRemove = bulkRemoveResponse; _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } } break; } return(_serializedResponse); }
public static IList <byte[]> BuildResponse(Hashtable removeResult, int commandVersion, string RequestId, IList <byte[]> _serializedResponse) { long requestId = Convert.ToInt64(RequestId); switch (commandVersion) { case 0: //Versions earlier than NCache 4.1 because all of them expect responses as one chunck { Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse bulkRemoveResponse = new Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse(); response.requestId = requestId; bulkRemoveResponse.keyValuePackage = Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysValues(removeResult, bulkRemoveResponse.keyValuePackage); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.REMOVE_BULK; response.bulkRemove = bulkRemoveResponse; _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } break; case 1: //Verion 4.1 or later { List <Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse> keyValuesPackageChuncks = Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysValues(removeResult); int sequenceId = 1; Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse bulkRemoveResponse = new Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse(); response.requestId = requestId; response.numberOfChuncks = keyValuesPackageChuncks.Count; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.REMOVE_BULK; foreach (Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse package in keyValuesPackageChuncks) { response.sequenceId = sequenceId++; bulkRemoveResponse.keyValuePackage = package; response.bulkRemove = bulkRemoveResponse; _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } break; } return(_serializedResponse); }
public static IList<byte[]> BuildResponse(Hashtable removeResult, int commandVersion, string RequestId, IList<byte[]> _serializedResponse) { long requestId = Convert.ToInt64(RequestId); switch (commandVersion) { case 0: //Versions earlier than NCache 4.1 because all of them expect responses as one chunck { Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse bulkRemoveResponse = new Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse(); response.requestId = requestId; bulkRemoveResponse.keyValuePackage = Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysValues(removeResult, bulkRemoveResponse.keyValuePackage); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.REMOVE_BULK; response.bulkRemove = bulkRemoveResponse; _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } break; case 1: //Verion 4.1 or later { List<Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse> keyValuesPackageChuncks = Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysValues(removeResult); int sequenceId = 1; Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse bulkRemoveResponse = new Alachisoft.NCache.Common.Protobuf.BulkRemoveResponse(); response.requestId = requestId; response.numberOfChuncks = keyValuesPackageChuncks.Count; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.REMOVE_BULK; foreach (Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse package in keyValuesPackageChuncks) { response.sequenceId = sequenceId++; bulkRemoveResponse.keyValuePackage = package; response.bulkRemove = bulkRemoveResponse; _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } break; } return _serializedResponse; }