10.25.0

IContextCreateSession Method

Creates a session instance. Session properties to customize the session, and message receive and the session event delegates must be provided for the session. The message receive delegate is invoked for each received message on this session. The session event delegate is invoked when session events occur, such as the session going up or down. Both delegates are invoked in the context of the context thread to which this session belongs.

Note: disposing the corresponding context (IContext) or any of its contained context timers (TimerTask), sessions (ISession) or flows (IFlow) must not be performed from within the registered delegates (messageEventHandler or sessionEventHandler).

Definition

Namespace: SolaceSystems.Solclient.Messaging
Assembly: SolaceSystems.Solclient.Messaging (in SolaceSystems.Solclient.Messaging.dll) Version: 10.25.0
C#
ISession CreateSession(
	SessionProperties props,
	EventHandler<MessageEventArgs> messageEventHandler,
	EventHandler<SessionEventArgs> sessionEventHandler
)

Parameters

props  SessionProperties
Defined in SessionProperties.
messageEventHandler  EventHandlerMessageEventArgs
A delegate for delivered messages.
sessionEventHandler  EventHandlerSessionEventArgs
A delegate for session events.

Client applications can call GetLastSDKErrorInfo from within the session event delegate to get more info on the type of error condition reported by SessionEventArgs.

Return Value

ISession
A new ISession instance.

Exceptions

OperationErrorException Thrown when unable to create the session. Possible sub-codes:
ObjectDisposedException Thrown if the context is already disposed (terminal state).
FatalErrorException Thrown when an unrecoverable error occurs.
ArgumentException Thrown when invalid values of SessionProperties property values are detected.

See Also