PWMediaSessionDelegate Protocol Reference

Conforms to NSObject
Declared in PWMediaSession.h

Overview

Used to send messages for an PWMediaSession instance. The PWMediaSession class includes a delegate property. When you send the [PWMediaSession startVideoCall:participant:displayName:delegate:] message, you specify an PWMediaSessionDelegate object.

Connect session

– mediaSession:didChangeState:

Sent when the client’s connection state changes.

- (void)mediaSession:(PWMediaSession *)session didChangeState:(PWConnectionState)state

Parameters

session

The PWMediaSession instance that sent this message.

state

The PWConnectionState instance that represents connection state.

Declared In

PWMediaSession.h

– mediaSession:didConnectToRoom: required method

Sent when the client is successfully connected and Created/Joined Room.

- (void)mediaSession:(PWMediaSession *)session didConnectToRoom:(PWRoom *)room

Parameters

session

The PWMediaSession instance that sent this message.

room

The PWRoom instance of a room in which client is connected.

Declared In

PWMediaSession.h

– mediaSession:didDisconnectToRoom: required method

Sent when the client disconnects from the session.

- (void)mediaSession:(PWMediaSession *)session didDisconnectToRoom:(PWRoom *)room

Parameters

session

The PWMediaSession instance that sent this message.

room

The PWRoom instance of a room from which client disconnects.

Declared In

PWMediaSession.h

– mediaSession:didFailWithError: required method

Sent when session fails to connect.

- (void)mediaSession:(PWMediaSession *)session didFailWithError:(NSError *)error

Parameters

session

The PWMediaSession instance that sent this message.

error

A NSError object describing the issue. kWebSocketErrorCode (defined in PWTypes.h) defines values for the code property of this object.

Declared In

PWMediaSession.h

Room

– mediaSession:shouldProcessNewPeer:

Sent right before when session starts connecting to new peer.

- (BOOL)mediaSession:(PWMediaSession *)session shouldProcessNewPeer:(PWRemotePeer *)remotePeer

Parameters

session

The PWMediaSession instance that sent this message.

remotePeer

The PWRemotePeer instance that represents new participant.

Return Value

return NO if client doesn’t want to connect to new peer. Default is YES.

Discussion

This delegate is used to control number of peers at client side.

Declared In

PWMediaSession.h

– mediaSession:didJoinNewPeer:

Sent when the new client joins room.

- (void)mediaSession:(PWMediaSession *)session didJoinNewPeer:(PWRemotePeer *)remotePeer

Parameters

session

The PWMediaSession instance that sent this message.

remotePeer

The PWRemotePeer instance that represents new participant.

Declared In

PWMediaSession.h

– mediaSession:didReceiveUsersList:

Sent when the client receives list of all participants in room.

- (void)mediaSession:(PWMediaSession *)session didReceiveUsersList:(nullable NSArray *)users

Parameters

session

The PWMediaSession instance that sent this message.

users

NSArray object of all participants (JSON) data.

Declared In

PWMediaSession.h

– mediaSession:didDisconnectPeer:

Sent when the other client disconnects from room.

- (void)mediaSession:(PWMediaSession *)session didDisconnectPeer:(PWRemotePeer *)remotePeer

Parameters

session

The PWMediaSession instance that sent this message.

remotePeer

The PWRemotePeer instance that represents participant disconnected from room.

Declared In

PWMediaSession.h

Get user media

– mediaSession:didAddLocalStream: required method

Sent when client got user-media.

- (void)mediaSession:(PWMediaSession *)session didAddLocalStream:(PWMediaStream *)localStream

Parameters

session

The PWMediaSession instance that sent this message.

localStream

PWMediaStream object of webrtc local media stream interface.

  • for getting audio: [localStream.audioTracks objectAtIndex:0]
  • for getting video: [localStream.videoTracks objectAtIndex:0]

Declared In

PWMediaSession.h

– mediaSession:didAddRemoteStream:ofPeer: required method

Sent when client got remote client user-media.

- (void)mediaSession:(PWMediaSession *)session didAddRemoteStream:(PWMediaStream *)remoteStream ofPeer:(PWRemotePeer *)remotePeer

Parameters

session

The PWMediaSession instance that sent this message.

remoteStream

PWMediaStream object of webrtc remote media stream interface.

  • for getting audio: [remoteStream.audioTracks objectAtIndex:0]
  • for getting video: [remoteStream.videoTracks objectAtIndex:0]
remotePeer

The PWRemotePeer instance that represents remote client of incoming media.

Declared In

PWMediaSession.h

Text message and file share

– mediaSession:didReceiveTextMessage:ofPeer:

Sent when client received text message, common for public/private message both.

- (void)mediaSession:(PWMediaSession *)session didReceiveTextMessage:(NSString *)message ofPeer:(PWRemotePeer *)remotePeer

Parameters

session

The PWMediaSession instance that sent this message.

message

NSString object contains text message.

remotePeer

The PWRemotePeer sender of message.

Declared In

PWMediaSession.h

– mediaSession:didStartReceivingDocument:

Sent when client is starting to receive file in chunks.

- (void)mediaSession:(PWMediaSession *)session didStartReceivingDocument:(PWDataFile *)document

Parameters

session

The PWMediaSession instance that sent this message.

document

The PWDataFile object which contains all the information of incoming data.

Declared In

PWMediaSession.h

– mediaSession:didFinishReceivingDocument:atURL:ofPeer:

Sent when client successfully received file.

- (void)mediaSession:(PWMediaSession *)session didFinishReceivingDocument:(nullable PWDataFile *)document atURL:(NSURL *)url ofPeer:(PWRemotePeer *)remotePeer

Parameters

session

The PWMediaSession instance that sent this message.

document

The PWDataFile object which contains all the information of received file.

url

The NSURL object which is a local path of received file.

remotePeer

The PWRemotePeer sender of file.

Declared In

PWMediaSession.h

– mediaSession:didFailFileTransferWithError:

Sent when file transfer failed when connection fails.

- (void)mediaSession:(PWMediaSession *)session didFailFileTransferWithError:(NSError *)error

Parameters

session

The PWMediaSession instance that sent this message.

error

A NSError object describing the issue.

Discussion

Reasons:

  • Slow internet connection.
  • Heavy usage of bandwidth.
  • Disconnected from server.
  • Data channels state close.

Declared In

PWMediaSession.h

WebRTC Statistics

– mediaSession:didGetStats:forPeer:

Sent on collect statistics event. when you send [PWMediaSession collectStatsWithTimeInterval:]

- (void)mediaSession:(PWMediaSession *)session didGetStats:(PWStatsBuilder *)statsReport forPeer:(PWRemotePeer *)remotePeer

Parameters

session

The PWMediaSession instance that sent this message.

statsReport

A PWStatsBuilder object describing the statistics of currently runnung connection.

remotePeer

An object of remote peer W.R.T stats.

Declared In

PWMediaSession.h