InfSimulatedConnection

InfSimulatedConnection — Simulated network connection

Stability Level

Unstable, unless otherwise indicated

Synopsis

#include <libinfinity/common/inf-simulated-connection.h>

                    InfSimulatedConnection;
struct              InfSimulatedConnectionClass;
enum                InfSimulatedConnectionMode;
InfSimulatedConnection * inf_simulated_connection_new   (void);
InfSimulatedConnection * inf_simulated_connection_new_with_io
                                                        (InfIo *io);
void                inf_simulated_connection_connect    (InfSimulatedConnection *connection,
                                                         InfSimulatedConnection *to);
void                inf_simulated_connection_set_mode   (InfSimulatedConnection *connection,
                                                         InfSimulatedConnectionMode mode);
void                inf_simulated_connection_flush      (InfSimulatedConnection *connection);

Object Hierarchy

  GObject
   +----InfSimulatedConnection
  GEnum
   +----InfSimulatedConnectionMode

Implemented Interfaces

InfSimulatedConnection implements InfXmlConnection.

Properties

  "io"                       InfIo*                : Read / Write / Construct Only
  "mode"                     InfSimulatedConnectionMode  : Read / Write / Construct
  "target"                   InfSimulatedConnection*  : Read / Write

Description

InfSimulatedConnection simulates a connection and can be used everywhere where a InfXmlConnection is expected. Use inf_simulated_connection_connect() to connect two such connections so that data sent through one is received by the other.

Details

InfSimulatedConnection

typedef struct _InfSimulatedConnection InfSimulatedConnection;

InfSimulatedConnection is an opaque data type. You should only access it via the public API functions.


struct InfSimulatedConnectionClass

struct InfSimulatedConnectionClass {
};

This structure does not contain any public fields.


enum InfSimulatedConnectionMode

typedef enum _InfSimulatedConnectionMode {
  INF_SIMULATED_CONNECTION_IMMEDIATE,
  INF_SIMULATED_CONNECTION_DELAYED,
  INF_SIMULATED_CONNECTION_IO_CONTROLLED
} InfSimulatedConnectionMode;

The mode of a simulated connection defines when sent messages arrive at the target connection.

INF_SIMULATED_CONNECTION_IMMEDIATE

Messages are received directly by the target site when calling inf_xml_connection_send().

INF_SIMULATED_CONNECTION_DELAYED

Messages are queued, and delivered to the target site when inf_simulated_connection_flush() is called.

INF_SIMULATED_CONNECTION_IO_CONTROLLED

Messages are queued and delivered once the application main loop regains control. This requires the simulated connection to have been created with inf_simulated_connection_new_with_io().

inf_simulated_connection_new ()

InfSimulatedConnection * inf_simulated_connection_new   (void);

Creates a new InfSimulatedConnection. A connection created this way cannot be switched to INF_SIMULATED_CONNECTION_IO_CONTROLLED mode. Use inf_simulated_connection_new_with_io() instead if you intend to do that.

Returns :

A new InfSimulatedConnection.

inf_simulated_connection_new_with_io ()

InfSimulatedConnection * inf_simulated_connection_new_with_io
                                                        (InfIo *io);

Creates a new InfSimulatedConnection with the given InfIo. This connection can be used with INF_SIMULATED_CONNECTION_IO_CONTROLLED mode. If you don't intend to use that mode then using inf_simulated_connection_new() is also good enough since the InfIo object is not required in that case.

io :

The main loop to be used for INF_SIMULATED_CONNECTION_IO_CONTROLLED mode.

Returns :

A new InfSimulatedConnection.

inf_simulated_connection_connect ()

void                inf_simulated_connection_connect    (InfSimulatedConnection *connection,
                                                         InfSimulatedConnection *to);

Connects two simulated connections, so that data sent through one of them is received by the other one and vice versa. So one call to this function connects both InfSimulatedConnections to each other. There is no need to call this function once for each connection.

If one or both of the connections already have another target, then the simulated connection between those is closed first.

connection :

A InfSimulatedConnection.

to :

The target connection.

inf_simulated_connection_set_mode ()

void                inf_simulated_connection_set_mode   (InfSimulatedConnection *connection,
                                                         InfSimulatedConnectionMode mode);

Sets the mode of the simulated connection.

In INF_SIMULATED_CONNECTION_IMMEDIATE mode, messages sent through the connection are received by the target during the call to inf_xml_connection_send().

In INF_SIMULATED_CONNECTION_DELAYED mode, messages sent are queued and received by the target when inf_simulated_connection_flush() is called.

In INF_SIMULATED_CONNECTION_IO_CONTROLLED mode, messages are queued and received by the target as soon as a dispatch handler (see inf_io_add_dispatch()) installed on the main loop is called.

When changing the mode from INF_SIMULATED_CONNECTION_DELAYED or INF_SIMULATED_CONNECTION_IO_CONTROLLED to INF_SIMULATED_CONNECTION_IMMEDIATE, then the queue is flushed, too.

connection :

A InfSimulatedConnection.

mode :

The new mode to set.

inf_simulated_connection_flush ()

void                inf_simulated_connection_flush      (InfSimulatedConnection *connection);

When connection's mode is INF_SIMULATED_CONNECTION_DELAYED or INF_SIMULATED_CONNECTION_IO_CONTROLLED, then calling this function makes the target connection receive all the queued messages.

connection :

A InfSimulatedConnection.

Property Details

The "io" property

  "io"                       InfIo*                : Read / Write / Construct Only

The main loop to be used for IO_CONTROLLED mode.


The "mode" property

  "mode"                     InfSimulatedConnectionMode  : Read / Write / Construct

The mode of the simulated connection.

Default value: INF_SIMULATED_CONNECTION_IMMEDIATE


The "target" property

  "target"                   InfSimulatedConnection*  : Read / Write

The simulated connection receiving data sent through this connection.