public static byte[] ToByteArray(this IMessage message) { Preconditions.CheckNotNull(message, "message"); byte[] result = new byte[message.CalculateSize()]; CodedOutputStream output = new CodedOutputStream(result); message.WriteTo(output); output.CheckNoSpaceLeft(); return result; }
/// <summary> /// Converts the given message into a byte array in protobuf encoding. /// </summary> /// <param name="message">The message to convert.</param> /// <returns>The message data as a byte array.</returns> public static byte[] ToByteArray(this IMessage message) { ProtoPreconditions.CheckNotNull(message, "message"); byte[] result = new byte[message.CalculateSize()]; CodedOutputStream output = new CodedOutputStream(result); message.WriteTo(output); output.CheckNoSpaceLeft(); return(result); }
public static byte[] ToByteArray(this IMessage message) { Preconditions.CheckNotNull <IMessage>(message, Module.smethod_33 <string>(879293356u)); byte[] expr_1C = new byte[message.CalculateSize()]; CodedOutputStream codedOutputStream = new CodedOutputStream(expr_1C); message.WriteTo(codedOutputStream); codedOutputStream.CheckNoSpaceLeft(); return(expr_1C); }
/// <summary> /// Converts the given message into a byte array in protobuf encoding. /// </summary> /// <param name="message">The message to convert.</param> /// <returns>The message data as a byte array.</returns> public static byte[] ToByteArray(this IMessage message) { ProtoPreconditions.CheckNotNull(message, "message"); byte[] result = null; CodedOutputStream output = GetOutSteam(message, out result); message.WriteTo(output); output.CheckNoSpaceLeft(); return(result); }
public void SendReq(GameState request, out String response) { byte[] bytes = new byte[request.CalculateSize()]; Google.Protobuf.CodedOutputStream codedOutputStream = new Google.Protobuf.CodedOutputStream(bytes); request.WriteTo(codedOutputStream); codedOutputStream.Flush(); codedOutputStream.CheckNoSpaceLeft(); networkStream.Write(bytes, 0, bytes.Length); networkStream.Flush(); byte[] toRead = new byte[tcpClient.ReceiveBufferSize]; int bytesRead = networkStream.Read(toRead, 0, tcpClient.ReceiveBufferSize); response = Encoding.UTF8.GetString(toRead, 0, bytesRead); }