Into

Modules

Documentation

classPiiNetworkOperation

#include <PiiNetworkOperation.h>

A base class for network input/output operations.

Inherits PiiDefaultOperation

Inherited by PiiNetworkInputOperation, PiiNetworkOutputOperation

Description

Subclasses of this class work as end points to network connections and make it possible to send/receive data to and from remote computers.

Inputs

bodythe body of a request or a response. Any data written to this input will be sent as the request/response body to the HTTP server/client. The body must be convertible to a QString. Any primitive type will do.
content typethe MIME type of the message body as a QString. This input is optional and cannot be connected alone. If the input is not connected, the contentType property will be used.
inputXa configurable number of optional input sockets. If these inputs are connected, body and content type must be left disconnected. The operation will encode the objects as defined by the #messageEncoding property. Use the inputNames property to change the number of inputs and their names.

Outputs

outputXa configurable number of outputs. X is a zero-based output index. You can assign arbitrary alias names to outputs with the outputNames property.
In PiiNetworkInputOperation, inputs should be connected as a feed-back loop. Incoming network requests will be decoded and sent to outputs. If no response is required, inputs can be left disconnected.
In PiiNetworkOutputOperation, inputs are encoded and sent to a server, whose response will be decoded and sent to the output sockets. If no response is received, no output will be produced.

Properties

The MIME type of the request/response body.

bool

Control the behavior of the operation in error conditions.

Input socket names.

Output socket names.

int

The maximum number of millisecond response data will be waited for.

Constructors and destructor

Public member functions

virtual void
(
  • bool reset
)

Checks the operation for execution.

bool
virtual PiiInputSocket *
( )

Finds input sockets by their alias names.

Returns the names of all inputs.

virtual PiiOutputSocket *
( )

Finds output sockets by their alias names.

Returns the names of all outputs.

int
void
( )
void
(
  • bool ignoreErrors
)
void
( )
void
( )
void
(
  • int responseTimeout
)

Protected member functions

void
( )

Read and decode an object from device and add it to the output value map with name.

void
( )

Add a variable to the output map.

void
(
  • const QVariantMap & variables
)

Add variables to the output map.

bool
( )

Read and decode objects from h and add them to the output value map.

void

Emit collected output values to named output sockets.

Property details

  • QString contentType

    [read, write]

    The MIME type of the request/response body.

    Used only if the body input is connected. If the content type input is connected, it overrides this value. The default value is text/plain.

  • bool ignoreErrors

    [read, write]

    Control the behavior of the operation in error conditions.

    If the flag is false (the default) the operation will signal an error and stop if the network connection is lost or the server/client sends invalid data.

  • QStringList inputNames

    [read, write]

    Input socket names.

    In PiiNetworkInputOperation, objects received in the named inputs will be encoded and sent back to the HTTP client as a response. In PiiNetworkOutputOperation, object received in the inputs will be encoded and sent to the server as a request.

  • QStringList outputNames

    [read, write]

    Output socket names.

    In PiiNetworkInputOperation, decoded HTTP request variables will be sent to the corresponding named outputs. In PiiNetworkOutputOperation, the variables decoded from the server's response will be sent.

  • int responseTimeout

    [read, write]

    The maximum number of millisecond response data will be waited for.

    In PiiNetworkInputOperation this is the time the operation will wait for data to appear in its loop-back input socket. If a response object is not received within time limits, the client will be sent an error message. In PiiNetworkOutputOperation, this is the time the operation will wait for a HTTP server to respond after the operation has sent a request.

    The default value is 5000.

Function details

  • ~PiiNetworkOperation

    ()
  • virtual void check

    (
    • bool reset
    )
    [virtual]

    Checks the operation for execution.

    This function creates a suitable flow controller by calling createFlowController(). It then sets the flow controller to the active processor and sets the processor as the input controller for all inputs.

    If you change socket groupings in your overridden implementation, please call PiiDefaultOperation::check() after that. Otherwise, your new groupings will not be in effect.

    Reimplemented from PiiDefaultOperation.

  • QString contentType

    ()
  • bool ignoreErrors

    ()
  • virtual PiiInputSocket * input

    ( )
    [virtual]

    Finds input sockets by their alias names.

    Reimplemented from PiiBasicOperation.

  • QStringList inputNames

    ()

    Returns the names of all inputs.

    Reimplemented from PiiOperation.

  • virtual PiiOutputSocket * output

    ( )
    [virtual]

    Finds output sockets by their alias names.

    Reimplemented from PiiBasicOperation.

  • QStringList outputNames

    ()

    Returns the names of all outputs.

    Reimplemented from PiiOperation.

  • int responseTimeout

    ()
  • void setContentType

    ( )
  • void setIgnoreErrors

    (
    • bool ignoreErrors
    )
  • void setInputNames

    ( )
  • void setOutputNames

    ( )
  • void setResponseTimeout

    (
    • int responseTimeout
    )
  • void addToOutputMap

    ( )
    [protected]

    Read and decode an object from device and add it to the output value map with name.

  • void addToOutputMap

    ( )
    [protected]

    Add a variable to the output map.

    This function tries to convert value into a PiiVariant. It recognizes integers, doubles and strings.

  • void addToOutputMap

    (
    • const QVariantMap & variables
    )
    [protected]

    Add variables to the output map.

  • bool decodeObjects

    ( )
    [protected]

    Read and decode objects from h and add them to the output value map.

  • void emitOutputValues

    ()
    [protected]

    Emit collected output values to named output sockets.

Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.