OTSessionDelegate

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.

Methods

Name Description
sessionDidConnect:(session) Sent when the client connects to the session.
sessionDidDisconnect:(session) Sent when the client disconnects from the session.
session:didFailWithError:(session, error) 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.
session:streamCreated:(session, stream) Sent when a new stream is created in this session.
session:streamDestroyed:(session, stream) Sent when a stream is no longer published to the session.
session:connectionCreated:(session, connection) Sent when another client connects to the session.
session:connectionDestroyed:(session, connection) Sent when another client disconnects from the session.
session:receivedSignalType:fromConnection:withString:(session, type, connection, string) Sent when a message is received in the session.
session:archiveStartedWithId:name:(session, archiveId, name) Sent when an archive recording of a session starts.
session:archiveStoppedWithId:(session, archiveId) Sent when an archive recording of a session stops.
sessionDidBeginReconnecting:(session) Sent when the local client has lost its connection to an OpenTok session and is trying to reconnect.
sessionDidReconnect:(session) Sent when the local client has reconnected to the OpenTok session after its network connection was lost temporarily.
session:muteForced:(session, muteForcedInfo) Sent when a moderator mutes streams in the session or disables the mute state in the session.

sessionDidConnect:(session)

Sent when the client connects to the session.

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.

sessionDidDisconnect:(session)

Sent when the client disconnects from the session.

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.

session:didFailWithError:(session, error)

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.

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.

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.
error OTError * An OTError object describing the issue. The OTSessionErrorCode enum defines values for the code property of this object.

session:streamCreated:(session, stream)

Sent when a new stream is created in this session.

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:].

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.
stream OTStream * The stream associated with this event.

session:streamDestroyed:(session, stream)

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

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.
stream OTStream * The stream associated with this event.

session:connectionCreated:(session, connection)

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

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.

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.
connection OTConnection * The new OTConnection object.

session:connectionDestroyed:(session, connection)

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

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.

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.
connection OTConnection * The OTConnection object for the client that disconnected from the session.

session:receivedSignalType:fromConnection:withString:(session, type, connection, string)

Sent when a message is received in the session.

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.
type NSString * The type string of the signal.
connection OTConnection * The connection identifying the client that sent the message. This value can be nil.
string NSString * The signal data.

session:archiveStartedWithId:name:(session, archiveId, 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.

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.

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.
archiveId NSString * The unique ID of the archive.
name NSString * The name of the archive (if one was provided when the archive was created).

session:archiveStoppedWithId:(session, archiveId)

Sent when an archive recording of a session stops.

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.

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.
archiveId NSString * The unique ID of the archive.

sessionDidBeginReconnecting:(session)

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.

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.

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.

sessionDidReconnect:(session)

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.

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:].

Parameters:
Name Type Description
session OTSession * The OTSession instance that sent this message.

session:muteForced:(session, muteForcedInfo)

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

See [OTSession forceMuteAll:error:], [OTSession capabilities], [OTPublisherKitDelegate muteForced:], and Muting the audio of streams in a session.

Parameters:
Name Type Description
session OTSession * The session.
muteForcedInfo OTMuteForcedInfo * 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.