public static ClusteredArrayList SerializeResponse(Alachisoft.NCache.Common.Protobuf.ManagementResponse command) { using (ClusteredMemoryStream stream = new ClusteredMemoryStream()) { //TODO byte[] size = new byte[10]; stream.Write(size, 0, size.Length); Serializer.Serialize <Alachisoft.NCache.Common.Protobuf.ManagementResponse>(stream, command); int messageLen = (int)stream.Length - size.Length; size = UTF8Encoding.UTF8.GetBytes(messageLen.ToString()); stream.Position = 0; stream.Write(size, 0, size.Length); ClusteredArrayList byteList = stream.GetInternalBuffer(); return(byteList); } }
public static byte[] SerializeResponse(Alachisoft.NCache.Common.Protobuf.ManagementResponse command) { using (MemoryStream stream = new MemoryStream()) { byte[] size = new byte[10]; stream.Write(size, 0, size.Length); Serializer.Serialize <Alachisoft.NCache.Common.Protobuf.ManagementResponse>(stream, command); int messageLen = (int)stream.Length - size.Length; size = UTF8Encoding.UTF8.GetBytes(messageLen.ToString()); stream.Position = 0; stream.Write(size, 0, size.Length); byte[] result = stream.ToArray(); stream.Close(); return(result); } }
public static byte[] SerializeManagementExceptionResponse(Exception exc, long requestId) { Alachisoft.NCache.Common.Protobuf.Exception ex = GetExceptionResponse(exc); Alachisoft.NCache.Common.Protobuf.ManagementResponse response = new ManagementResponse(); response.requestId = requestId; response.exception = ex; return SerializeResponse(response); }