INetworkRequest

class

Interface class that defines a generic network request. Network request have a notion of 3 states:

  1. setup
  2. in progress
  3. completed
  4. error

Public Functions

INetworkRequest::States INetworkRequest::State()
const

Get the current state of the underlying network request.

PUBLIC METHODS.

Return
The current state of the request

bool INetworkRequest::IsCompleted()
const

Check to see if the underlying network request has finished and are in the COMPLETE_STATE

Return
true if the request is completed

bool INetworkRequest::HasFailed()
const

Check to see if the underlying network has failed, and are in ERROR_STATE

Return
true if the request has failed

template <typename Owner>
void mono::network::INetworkRequest::setCompletionCallback(Owner * cnxt, void(Owner::*)( CompletionEvent *) memPtr)

Set the completion handler callback function.

To receive a notification callback when the underlying network request finishes successfully, use this method to install a callback function.

Parameters
  • cnxt -

    A pointer to the callback context (the this pointer)

  • memPtr -

    A pointer to the context class’ member function

void mono::network::INetworkRequest::setCompletionCallback(void (*cfunc)(CompletionEvent *))

Set the completion handler callback function.

To receive a notification callback when the underlying network request finishes successfully, use this method to install a callback function.

Parameters
  • cfunc -

    A pointer to the function handling completion

template <typename Owner>
void mono::network::INetworkRequest::setErrorCallback(Owner * cnxt, void(Owner::*)( ErrorEvent *) memPtr)

Set an error handler callback function.

To receive a notification callback if this request fails, set a callback function here.

Parameters
  • cnxt -

    A pointer to the callback context (the this pointer)

  • memPtr -

    A pointer to the context class’ member function

void mono::network::INetworkRequest::setErrorCallback(void (*cfunc)(ErrorEvent *))

Set an error handler callback function.

To receive a notification callback if this request fails, set a callback function here.

Parameters
  • cfunc -

    A pointer to the function handling errors

template <typename Owner>
void mono::network::INetworkRequest::setStateChangeEventCallback(Owner * cnxt, void(Owner::*)( StateChangeEvent *) memPtr)

Set a state change observer callback.

To receive notifications of state changes to the underlying network request, install a callback function with this method.

Parameters
  • cnxt -

    A pointer to the callback context (the this pointer)

  • memPtr -

    A pointer to the context class’ member function

void mono::network::INetworkRequest::setStateChangeEventCallback(void (*cfunc)(StateChangeEvent *))

Set a state change observer callback.

To receive notifications of state changes to the underlying network request, install a callback function with this method.

Parameters
  • cfunc -

    A pointer to the function handling request state changes

Protected Functions

void INetworkRequest::setState(States newState)

set new states and trigger stateCHange callback if state changed

void INetworkRequest::triggerCompletionHandler()

calls the completion handler

void INetworkRequest::triggerDirectErrorHandler()

call the error handler, directly

void INetworkRequest::triggerQueuedErrorHandler()

call the error callback, from the run queue

mono::network::INetworkRequest::INetworkRequest()

A new network request in SETUP state

Protected Attributes

mbed::FunctionPointerArg1<void, CompletionEvent *> mono::network::INetworkRequest::completionHandler

Handler called upon successfull completion of request.

mbed::FunctionPointerArg1<void, ErrorEvent *> mono::network::INetworkRequest::errorHandler

Handler called upon any error (transition into ERROR_STATE)

mbed::FunctionPointerArg1<void, StateChangeEvent *> mono::network::INetworkRequest::stateChangeHandler

handler called whenever the states changes

States mono::network::INetworkRequest::state

the current state of the request

int mono::network::INetworkRequest::lastErrorCode

holds the latest error code, 0 = no error

Timer *mono::network::INetworkRequest::cbTimer

queued callback timer object