Stream
Object Hierarchy:
Description:
public class Stream : Object
Per-connection bin codec — write and parse Serializable objects.
Owns the I/O streams and even/odd wire-name tables for one channel. OLLMrpc.Client and
OLLMrpc.Transport.Connection keep one Stream for the connection lifetime.
Call write to send a root object;
parse to receive one.
Example
OLLMrpc.Bin.register("Pair", typeof(Pair));
var mem = new GLib.MemoryOutputStream.resizable();
var out_stream = new GLib.DataOutputStream(mem);
var write_bin = new OLLMrpc.Bin.Stream(null, out_stream);
write_bin.write(new Pair() { name = "alpha", count = 42 });
out_stream.close();
var read_bin = new OLLMrpc.Bin.Stream(
new GLib.DataInputStream(
new GLib.MemoryInputStream.from_bytes(mem.steal_as_bytes())),
null);
var parsed = read_bin.parse() as Pair;
Pass null for the unused direction in memory-only tests.
See also:
Serializable, register
Content:
Constants:
Properties:
Creation methods:
- public Stream (DataInputStream? in_stream, DataOutputStream? out_stream, bool is_server = false)
Methods:
- public Serializable parse () throws Error
- public Object parse_object (Type object_type = INVALID, Type expected_type = INVALID) throws Error
Read one object body after its GLib.Type.OBJECT
type byte.
- public ArrayList<Object> parse_object_array () throws Error
Homogeneous object-array body after wire byte 0xD0: element
class, count, then one property stream per element.
- public Type read_gtype () throws Error
Read reg_id after an object type byte; return registered gtype.
- public void write (Serializable obj, Buffer? buffer = null) throws Error
- public void write_gtype (Type object_type, uint8 type_byte = ( uint8) OBJECT) throws Error
- public void write_tag (string prop_name) throws Error
Inherited Members:
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref