OTSessionDelegate Protocol Reference

Conforms to NSObject
Declared in OTSession.h

Overview

Used to send messages for an OTSession instance. The OTSession class includes a delegate property. When you send the [OTSession initWithApiKey:sessionId:delegate:] message, you specify an OTSessionDelegate object.

Connecting to a session

– sessionDidConnect: required method

Sent when the client connects to the session.

- (void)sessionDidConnect:(nonnull OTSession *)session

Parameters

session

The OTSession instance that sent this message.

Declared In

OTSession.h

– sessionDidDisconnect: required method

Sent when the client disconnects from the session.

- (void)sessionDidDisconnect:(nonnull OTSession *)session

Parameters

session

The OTSession instance that sent this message.

Declared In

OTSession.h

– session:didFailWithError: required method

Sent if the attempt to connect to the session fails or if the connection to the session drops due to an error after a successful connection.

- (void)session:(nonnull OTSession *)session didFailWithError:(nonnull OTError *)error

Parameters

session

The OTSession instance that sent this message.

error

An OTError object describing the issue. The OTSessionErrorCode enum defines values for the code property of this object.

Discussion

This message is sent after your application calls [OTSession connectWithToken:error:].

If this message is sent because the connection to the session drops after a successful connection, the message is sent just before the [OTSessionDelegate sessionDidDisconnect:] message is sent.

Declared In

OTSession.h

Monitoring streams in a session

– session:streamCreated: required method

Sent when a new stream is created in this session.

- (void)session:(nonnull OTSession *)session streamCreated:(nonnull OTStream *)stream

Parameters

session

The OTSession instance that sent this message.

stream

The stream associated with this event.

Discussion

Note that if your application publishes to this session, your own session delegate will not receive the [OTSessionDelegate session:streamCreated:] message for its own published stream. For that event, see the delegate callback [OTPublisherKitDelegate publisher:streamCreated:].

Declared In

OTSession.h

– session:streamDestroyed: required method

Sent when a stream is no longer published to the session.

- (void)session:(nonnull OTSession *)session streamDestroyed:(nonnull OTStream *)stream

Parameters

session

The OTSession instance that sent this message.

stream

The stream associated with this event.

Declared In

OTSession.h

Monitoring connections in a session

– session:connectionCreated:

Sent when another client connects to the session. The connection object represents the client’s connection.

- (void)session:(nonnull OTSession *)session connectionCreated:(nonnull OTConnection *)connection

Parameters

session

The OTSession instance that sent this message.

connection

The new OTConnection object.

Discussion

This message is not sent when your own client connects to the session. Instead, the [OTSessionDelegate sessionDidConnect:] message is sent when your own client connects to the session.

Declared In

OTSession.h

– session:connectionDestroyed:

Sent when another client disconnects from the session. The connection object represents the connection that the client had to the session.

- (void)session:(nonnull OTSession *)session connectionDestroyed:(nonnull OTConnection *)connection

Parameters

session

The OTSession instance that sent this message.

connection

The OTConnection object for the client that disconnected from the session.

Discussion

This message is not sent when your own client disconnects from the session. Instead, the [OTSessionDelegate sessionDidDisconnect:] message is sent when your own client connects to the session.

Declared In

OTSession.h

– session:receivedSignalType:fromConnection:withString:

Sent when a message is received in the session.

- (void)session:(nonnull OTSession *)session receivedSignalType:(NSString *_Nullable)type fromConnection:(OTConnection *_Nullable)connection withString:(NSString *_Nullable)string

Parameters

session

The OTSession instance that sent this message.

type

The type string of the signal.

connection

The connection identifying the client that sent the message. This value can be nil.

string

The signal data.

Declared In

OTSession.h

Monitoring archiving events

– session:archiveStartedWithId:name:

Sent when an archive recording of a session starts. If you connect to a session in which recording is already in progress, this message is sent when you connect.

- (void)session:(nonnull OTSession *)session archiveStartedWithId:(nonnull NSString *)archiveId name:(NSString *_Nullable)name

Parameters

session

The OTSession instance that sent this message.

archiveId

The unique ID of the archive.

name

The name of the archive (if one was provided when the archive was created).

Discussion

In response to this message, you may want to add a user interface notification (such as an icon in the Publisher view) that indicates that the session is being recorded.

For more information see the OpenTok Archiving Overview.

Declared In

OTSession.h

– session:archiveStoppedWithId:

Sent when an archive recording of a session stops.

- (void)session:(nonnull OTSession *)session archiveStoppedWithId:(nonnull NSString *)archiveId

Parameters

session

The OTSession instance that sent this message.

archiveId

The unique ID of the archive.

Discussion

In response to this message, you may want to change or remove a user interface notification (such as an icon in the Publisher view) that indicates that the session is being recorded.

For more information, see the OpenTok Archiving Overview.

Declared In

OTSession.h

Reconnecting to a session

– sessionDidBeginReconnecting:

Sent when the local client has lost its connection to an OpenTok session and is trying to reconnect. This results from a loss in network connectivity. If the client can reconnect to the session, the [OTSessionDelegate sessionDidReconnect:] message is sent. Otherwise, if the client cannot reconnect, the [OTSessionDelegate sessionDidDisconnect:] message is sent.

- (void)sessionDidBeginReconnecting:(nonnull OTSession *)session

Parameters

session

The OTSession instance that sent this message.

Discussion

In response to this message being sent, you may want to provide a user interface notification, to let the user know that the app is trying to reconnect to the session and that audio-video streams are temporarily disconnected.

Declared In

OTSession.h

– sessionDidReconnect:

Sent when the local client has reconnected to the OpenTok session after its network connection was lost temporarily. When the connection is lost, the [OTSessionDelegate sessionDidBeginReconnecting:] message is sent, prior to the [OTSessionDelegate sessionDidReconnect:] messsage. If the client cannot reconnect to the session, the [OTSessionDelegate sessionDidDisconnect:] message is sent.

- (void)sessionDidReconnect:(nonnull OTSession *)session

Parameters

session

The OTSession instance that sent this message.

Discussion

Any existing publishers and subscribers are automatically reconnected when the client reconnects and this message is sent.

By default, any signals initiated by the local client using the [OTSession signalWithType:string:connection:error:] method are sent when the client reconnects. To prevent any signals initiated while disconnected from being sent, use the [OTSession signalWithType:string:connection:retryAfterReconnect:error:] method to send the signal, and set the retryAfterReconnect parameter to NO. (All signals sent by other clients while your client was disconnected are received upon reconnecting.)

See [OTSessionDelegate sessionDidBeginReconnecting:].

Declared In

OTSession.h

Monitoring mute state changes

– session:muteForced:

Sent when a moderator mutes streams in the session or disables the mute state in the session.

- (void)session:(nonnull OTSession *)session muteForced:(nonnull OTMuteForcedInfo *)muteForcedInfo

Parameters

session

The session.

muteForcedInfo

Check the active property of this object. When it is set to YES, the moderator has muted streams in the session. When it is set to NO, a moderator has disabled the mute state in the session.

Declared In

OTSession.h