Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.network.multiplayer

Class EM_NET_CONNECTION


Direct ancestors

EM_NET_EVENT_PROCESSOR

Creation

Features

Invariants

indexing

description

Represents a connection to a remote peer.

Input and output is not directly done via the connection but via the groups a connection
belongs to:

Every connection has a predefined personal_group that can be used for data sending and
receival with only one specific peer (that is the other side of the connection).

A connection may join multiple groups. You can also define your own group. Data transfer on such
a group concerns all connections that have joined the corresponding group.

See EM_NET_GROUP for further details.

date

$Date: 2005/10/24 12:47:42 $

revision

$Revision: 1.11 $

class

EM_NET_CONNECTION

inherit

EM_NET_EVENT_PROCESSOR

create

make

-- Initialisation

feature -- Initialization

make

-- Initialisation

feature -- Element change

set_last_update (a_receive_time: INTEGER)

-- Set receive_time to a_receive_time.

ensure
last_update_set: last_receive_time = a_receive_time
set_max_idle_time (an_idle_time: INTEGER)

-- Set socket_address to a_socket_address.

require
an_natural_idle_time: an_idle_time >= 0
ensure
max_idle_time_set: max_idle_time = an_idle_time
set_personal_group (a_personal_group: EM_NET_GROUP)

-- Set personal_group to a_personal_group.

require
a_personal_group_not_void: a_personal_group /= Void
ensure
personal_group_set: personal_group = a_personal_group
set_socket_address (a_socket_address: EM_INET_SOCKET_ADDRESS)

-- Set socket_address to a_socket_address.

require
a_socket_address_not_void: a_socket_address /= Void
ensure
socket_address_set: socket_address = a_socket_address
subscribe_by_event (an_event: EM_NET_EVENT_OBJECT; a_procedure: PROCEDURE [ANY, TUPLE])

-- Subscribe a_procedure to an_event.

-- (From EM_NET_EVENT_PROCESSOR)

subscribe_by_type_id (an_event_type_id: INTEGER; a_procedure: PROCEDURE [ANY, TUPLE])

-- Subscribe a_procedure to an event with an_event_type_id.

-- (From EM_NET_EVENT_PROCESSOR)

unsubscribe_by_event (an_event: EM_NET_OBJECT; a_procedure: PROCEDURE [ANY, TUPLE])

-- Unsubscribe a_procedure from an_event.

-- (From EM_NET_EVENT_PROCESSOR)

unsubscribe_by_type_id (an_event_type_id: INTEGER; a_procedure: PROCEDURE [ANY, TUPLE])

-- Unsubscribe a_procedure from an event with an_event_type_id.

-- (From EM_NET_EVENT_PROCESSOR)

feature -- Actions

join (a_group: EM_NET_GROUP)

-- Join a_group.

require
a_group_not_void: a_group /= Void
not_already_member_of_a_group: not a_group.has_connection(Current)
ensure
group_joined: a_group.has_connection(Current)
leave (a_group: EM_NET_GROUP)

-- Leave a_group.

require
a_group_not_void: a_group /= Void
member_of_a_group: a_group.has_connection(Current)
ensure
group_left: not a_group.has_connection(Current)
leave_all_groups

-- Leave all groups.

feature -- Publishing

publish (an_event: EM_NET_EVENT_OBJECT)

-- Publish an_event to the event queue.

-- (From EM_NET_EVENT_PROCESSOR)

feature -- Attributes

groups: DS_LINKED_LIST[EM_NET_GROUP]

-- List of groups that this connection belongs to

last_receive_time: INTEGER

-- Last time of incoming network activity in ms

max_idle_time: INTEGER

-- Max idle duration
-- If max_idle_time is exceeded a timeout event will be generated.

personal_group: EM_NET_GROUP

-- Personal group

timeout_event: EM_EVENT_TYPE[TUPLE[EM_NET_CONNECTION]]

-- Timeout event

invariant

invariant_clause: True


-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end