Derive message from GLib.Object

Bug #1283466 reported by ECC_OK
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Protocol Buffer Vala Support
Wishlist
Unassigned

Bug Description

Protobuf.Message should derive from GLib.Object which makes it possible to use RTTI on them.

Changed in protobuf-vala:
status: New → Triaged
importance: Undecided → Wishlist
Revision history for this message
Robert Ancell (robert-ancell) wrote :

What sort of operation specifically did you want to use? I intentionally didn't extend GLib.Object as this would have more overhead for no particular benefit.

Changed in protobuf-vala:
status: Triaged → Incomplete
Revision history for this message
ECC_OK (prometheus-unterderbruecke) wrote :

I am currently writing a Mumble compatible voicechat application.

Mumble uses a TCP connection and prepends every protobuf message with a header that specifies the message kind.

I am using typeof(...) to store the types of the protobuf messages in a hash map:

  this.message_types = new Gee.HashMap<int, Type> ();
  this.message_types[ 0] = typeof(Mumble.Version);
  this.message_types[ 1] = typeof(Mumble.UDPTunnel);
  this.message_types[ 2] = typeof(Mumble.Authenticate);

This makes both creation of objects from the header and creating the header from the object much easier.

Receiving:

  if (this.message_types.has_key (prefix.message_type)) {
   var type = this.message_types[prefix.message_type];
   Protobuf.Message msg = Object.new (type) as Protobuf.Message;
   if (msg is Mumble.UDPTunnel) {

Sending:

  prefix.message_type = this.type_messages[message.get_type ()];

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers