WS_SERVICE_ACCEPT_CHANNEL_CALLBACK callback function (webservices.h)

Invoked when a channel is accepted on an endpoint listener by service host.

For session-based service contract, this notification signifies session initiation. Thus an application state scoped for the session can be created within this callback.

Syntax

WS_SERVICE_ACCEPT_CHANNEL_CALLBACK WsServiceAcceptChannelCallback;

HRESULT WsServiceAcceptChannelCallback(
  [in]           const WS_OPERATION_CONTEXT *context,
                 void **channelState,
  [in, optional] const WS_ASYNC_CONTEXT *asyncContext,
  [in, optional] WS_ERROR *error
)
{...}

Parameters

[in] context

The operation context.

channelState

The callback may provide channel state through this parameter. This channel state is made available to the service operation as part of WS_OPERATION_CONTEXT through the WS_OPERATION_CONTEXT_PROPERTY_CHANNEL_USER_STATE.

[in, optional] asyncContext

Information on whether the function is getting invoked asynchronously.

[in, optional] error

Specifies where additional error information should be stored if the function fails.

Return value

This callback function does not return a value.

Remarks

See also WS_SERVICE_CLOSE_CHANNEL_CALLBACK which can be used by the application to disassociate state, and gets called on channel closure.

This callback is cancellable.

Examples

For an example implementation on how to use this callback for associating session state, see the session based calculator sample.

HRESULT CALLBACK CreateSessionCalculator (const WS_OPERATION_CONTEXT* context, void** userChannelState,
                                          const WS_ASYNC_CONTEXT* asyncContext, WS_ERROR* error)
{
    SessionfullCalculator* calculator = new SessionfullCalculator ();
    if (calculator != NULL)
        *userChannelState = (void*) calculator;
    else
        return E_OUTOFMEMORY;
    return NOERROR;
}

Requirements

Requirement Value
Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header webservices.h