Suggestions

close search

StringeeConnectionDelegate

@protocol StringeeConnectionDelegate <NSObject>

Used to monitors the client's connection.

- didConnect:isReconnecting:

Invoked when the client connects to Stringee server:
- stringeeClient: The StringeeClient instance.
- isReconnecting = YES: The client is reconnecting.
- isReconnecting = NO: The client connects first time.

- (void)didConnect:(StringeeClient *)stringeeClient isReconnecting:(BOOL)isReconnecting;
- didDisConnect:isReconnecting:

Invoked when the client disconnects from Stringee server:
- stringeeClient: The StringeeClient instance.
- isReconnecting = YES: The client is reconnecting.
- isReconnecting = NO: The client connects first time.

- (void)didDisConnect:(StringeeClient *)stringeeClient isReconnecting:(BOOL)isReconnecting;
- didFailWithError:code:message:

Invoked when the client fails to connect to Stringee server: 
- stringeeClient: The StringeeClient instance.
- code = 1, message = "Access token is empty"
- code = 2, message = "Access token can not be decoded"
- code = 3, message = "Access token invalid format"
- code = 4, message = "Access token does not use HS256"
- code = 5, message = "API key sid or account sid not found"
- code = 6, message = "Access token expired or invalid"
- code = 7, message = "Access token invalid payload"
- code = 8, message = "Project not found"

From SDK 2.2.0, when the access token expires without being renewed, the server disconnects the client: this method is invoked with code = 6, then requestAccessToken: is invoked. The client does not reconnect with the expired token.

- (void)didFailWithError:(StringeeClient *)stringeeClient code:(int)code message:(NSString *)message;
- requestAccessToken:

Invoked when the access token is expired. You must get a new token and reconnect:
- stringeeClient: The StringeeClient instance.

From SDK 2.2.0, this method is also invoked in these cases:
- About 60 seconds before the access token expires, if your delegate does not implement tokenWillExpire:exp:expireInSeconds:. Get a new token for the same user and call connectWithAccessToken: with it: the token is renewed on the open connection without reconnecting.
- After the token expired without being renewed and the server disconnected the client (didFailWithError:code:message: is invoked first with code = 6). The client does not reconnect with the expired token: call connectWithAccessToken: with a new token on the same StringeeClient instance to resume the session.

- (void)requestAccessToken:(StringeeClient *)stringeeClient;
- tokenWillExpire:exp:expireInSeconds:

Optional. Invoked about 60 seconds before the access token expires, on servers that support token expiration. Get a new token for the same user from your server and call updateToken:completionHandler: to renew it on the open connection without reconnecting. If you do not implement this method, requestAccessToken: is invoked instead. If the token is not renewed, the server disconnects the client when the token expires. During a StringeeCall voice call, the server waits until the call ends before disconnecting; it does not wait for a StringeeCall2 call, so renew the token as soon as this method is invoked. Available from SDK 2.2.0:
- stringeeClient: The StringeeClient instance.
- exp: Expiration time of the access token, in seconds since the epoch.
- expireInSeconds: Seconds left before the access token expires.

- (void)tokenWillExpire:(StringeeClient *)stringeeClient exp:(long long)exp expireInSeconds:(int)expireInSeconds;
- didReceiveCustomMessage:message:fromUserId

Invoked when the client receives a custom message from another client:
- stringeeClient: The StringeeClient instance.
- message: Custom message from another client
- userId: User id of the sender.

- (void)didReceiveCustomMessage:(StringeeClient *)stringeeClient message:(NSDictionary *)message fromUserId:(NSString *)userId;