indexing description: "[ Represents an object than can be transmitted over a network. ]" date: "$Date$" revision: "$Revision$" deferred class EM_NET_OBJECT inherit EM_NETWORK_CONSTANTS export {NONE} all end feature -- Initialization make_set_type (a_type_id: INTEGER) is -- Create an instance and set `type_id' to `a_type_id'. do type_id := a_type_id is_make_set_type_called := True end make_from_stream (an_unserializer: EM_NET_UNSERIALIZER) is -- Initialize object with data from `an_unserializer'. -- The default behaviour uses the `unserialize' feature. -- If you have other/extended initialization data you need to redefine this feature. -- Note: There is no need to serialize the type ID, this is done automatically. -- This function will usually be called by the EM_NET_OBJECT_GENERATOR class. do unserialize (an_unserializer) end serialize_init_data (a_serializer: EM_NET_SERIALIZER) is -- Serialize initialization data to the given stream using `a_serializer'. -- The default behaviour uses the `serialize' feature. -- If you redefine `make_from_stream', you'll also have to redefine this feature. -- Note: There is no need to serialize the type ID, this is done automatically. do serialize (a_serializer) end init_serialization_byte_count: INTEGER is -- Count of bytes needed for a successful serialization of initialization data. -- The default behaviour uses the `serialize_byte_count' feature. -- If you redefine `serialize_init_data', you'll also to redefine this feature. -- This might be a constant and *could* be a dynamic value. -- {EM_NET_WORK_CONSTANTS}.max_serialization_byte_count is the limit! do Result := serialization_byte_count end feature -- Serialization serialize (a_serializer: EM_NET_SERIALIZER) is -- Serialize to the given stream using `a_serializer'. require a_serializer_not_void: a_serializer /= Void deferred end serialization_byte_count: INTEGER is -- Count of bytes needed for a successful serialization -- This might be a constant and *could* be a dynamic value. -- {EM_NET_WORK_CONSTANTS}.max_serialization_byte_count is the limit! deferred ensure Result_in_max_serialization_byte_count_range: Result <= max_serialization_byte_count.item end unserialize (an_unserializer: EM_NET_UNSERIALIZER) is -- Unserialize from a given stream using `an_unserializer'. require a_unserializer_not_void: an_unserializer /= Void deferred end feature {EM_NET_OBJECT_ID_MANAGER, EM_NET_OBJECT_TYPES, EM_NET_CREATE_OBJECT_RESPONSE} -- Element change set_id (an_id: INTEGER) is -- Set `id' to `an_id'. do id := an_id ensure id_correct_set: an_id = id end feature {EM_NET_BASE,EM_NET_EVENT_CONTAINER_OBJECT}-- Element change set_group (a_group: EM_NET_GROUP) is -- Set `group' to `a_group'. -- Note that an object can only belong to one group. -- If you set a new group, the object should be removed from the previous one first. require not_already_added_to_a_group: not a_group.has_object (Current) do if group /= Void then group.remove_object (Current) else group := a_group group.add_object (Current) end ensure group_set: group = a_group end set_updating_connection (a_connection: EM_NET_CONNECTION) is -- Set `updating_connection' to `a_connection'. require a_connection_not_void: a_connection /= Void do updating_connection := a_connection ensure updating_connection_set: updating_connection = a_connection end set_time_offset (a_time: INTEGER) is -- Set `last_update' to `a_time'. do time_offset := a_time ensure last_update_set: time_offset = a_time end feature -- Information id: INTEGER -- Unique ID that indentifies a single instance of an object type_id: INTEGER -- ID that identifies the type of of an on object is_make_set_type_called: BOOLEAN -- Has `make_set_type' been called? is_synchronized: BOOLEAN -- Is this object currently synchronized over network? -- True if this object is added to a server or client list for synchronisation. is_synchronisation_needed : BOOLEAN is -- Is synchronisation needed? -- False by default. do Result := False end next_sync_frame: INTEGER -- Next time when object synchronisation occurs group: EM_NET_GROUP -- Group that contains the current object -- The object will be synchronized with all clients that are in -- the same group. updating_connection: EM_NET_CONNECTION -- Connection which sent the last update time_offset: INTEGER -- Time in miliseconds of the lastupdate feature {NONE} -- Implementation invariant type_id_set_by_factory: type_id > 0 and is_make_set_type_called end