Society buffer message through AKKA IO and socket

I came across this blog post and I found it great and instructive, showing how to build a fixed-length string message sent to the Akka IO socket server I have been using the open source library I found here called ScalaBuff, which creates a nice thin layer on top of the protocol buffer object.

The trouble I have is adjusting the blogger (Can’t find the link to contact him directly) Code to get the length (4-byte sequence) and then the protobuf byte array. I can worry about finding out which message is online later, and now I just want the code to use a sample message.

My problem is that I cannot convert Akka IO code from akka ByteStrings to be able to send and pull raw bytes from protobuf messages. This is one that I am not familiar with using Akka IO socket servers Kind of performance. I can get from the byte representation of my protobuf object (Zombie Sighting), but I cannot get samples from the blog to deal with byte arrays instead of strings.

If anyone has some Suggestions, some sample code, or some input on how to get from point A (the blog post mentioned above) to point B (an Akka IO socket client that sends a protobuf message to the Akka IO socket server)…I I think I have client work…maybe), it would be great.

try This:

val myByteArray = myByteString.toArray // converts to an Array[Byte]
val myMessage = MyMessage.defaultInstance.mergeFrom(myByteArray)< /pre>

MyMessage is a class generated by the ScalaBuff compiler using the MyMessage.proto template. Please note that the Google protobuf library has a separate ByteString class, please make sure not to mix the two classes.

Update: Kevin’s problem has been solved, basically the problem is that he is using the toString method of an array [Byte] instead of wrapping the byte array in a new String(), which correctly wraps the byte array Converted to a string for use in "%s" .Format call.

I came across this blog post, and I found it great and instructive, showing how to send to the Akka IO socket server String messages are built with a fixed length. I have been using the open source library I found here called ScalaBuff, which creates a nice thin layer on top of the protocol buffer object.

I The trouble I encountered was adjusting the blogger's code (can't find the link to contact him directly) to get the length (4-byte sequence) and then the protobuf byte array. I can worry about finding out which message is online in the future, and now I only I want the code to use a sample message.

My problem is that I can’t convert the Akka IO code from akka ByteStrings to be able to send and pull raw bytes from protobuf messages. This is how I use Akka IO A manifestation that the socket server is not familiar with. I can get it from the byte representation of my protobuf object (Zombie Sighting), but I can't get a sample from the blog to deal with byte arrays instead of strings.

If anyone has some suggestions, some sample code, or how to go from point A (the blog post mentioned above) to point B (an Akka IO socket client, send a protobuf message to the Akka IO socket Word server) some input...I think I have a client job...maybe), it would be great.

Try this:

val myByteArray = myByteString.toArray // converts to an Array[Byte]
val myMessage = MyMessage.defaultInstance.mergeFrom(myByteArray)

< p>MyMessage is a class generated by the ScalaBuff compiler using the MyMessage.proto template. Please note that the Google protobuf library has a separate ByteString class, please make sure not to mix these two classes.

Update: Kevin The problem has been solved, basically the problem is that he uses the toString method of an array [Byte] instead of wrapping the byte array in a new String(), which correctly converts the byte array to a string , Used for "%s". format call.

Leave a Comment

Your email address will not be published.