Archived

This forum has been archived. Please start a new discussion on GitHub.

How to split an ice request

Alexandre
Alexandre Lyon, France

Hello everyone,

I've been struggling today on one issue and I'd like to know if what I want is even possible.
Before the question, here is a quick summary.

Basically I've got a simple system sending and receiving "Messages".

// Base message class.
class Message
{
    MessageType type; 
}

Every message of my system inherits from this class. The MessageType allows me, when a message is received, to downcast the received Message to its proper class, for example:

class UpdateEntityBoundsMessage extends Message
{
    int uid;
    BoundingBox bounds;
}

I've create a simple system to allow for message batching using the following slice:

sequence<Message> MessageList;
class MessageBatch extends Message
{
    MessageList messages;
}

When I receive a MessageBatch, I simply iterate through all messages, downcast them, and process.

Now the actual question: I'm trying to do the opposite of batching, ie. splitting the data into smaller chunks, if the message size exceeds the max payload size. I don't want to make the maximum payload size too big.

I'm trying to prototype something that would look like:

class MessageChunk extends Message
{
    int messageUid;
    int chunkCount;
    int chunkId;
    ByteArray data;
}

Where one can send a bigger message into smaller chunks of data. But since messages are not structs, I don't see any way to convert a message to a byte array... besides adding another serialization layer.

Is there any easy way with ice to do the same thing with a builtin feature?
Is there any way with ice to serialize a message to a byte array ?

Hope this is clear enough and someone can help with that.
I'd hate to have to come to a splitting mechanism per message type, and would prefer to have that on the base class.

Thank you,
Keep up the good work !

Comments