JCClient

Overview

JCClient is the main interface to manage a JumpChat session. Events can be handled through the JCClientDelegate protocol.

Inherits

@interface JCClient : NSObject

Properties

room

The name of the room that is joined. nil otherwise.

@property (nonatomic, readonly) NSString *room;

password

Password of the room if locked. Empty string otherwise.

@property (nonatomic, copy) NSString *password;

username

Username of the user. By default, it is the device name if not set.

@property (nonatomic, copy) NSString *username;

avatar

Avatar of the user. By default, it is the default-avatar.jpg file in the JumpChatSDK.bundle directory.

@property (nonatomic, copy) UIImage *avatar;

captureFrontCamera

State of which camera to capture. Front or back.

@property (nonatomic, readonly) BOOL captureFrontCamera;

messages

Array of text messages. Each message is a NSDictionary that has the following keys.

userid:User id of the person. me if it’s your own message.
message:String of the message.
timestamp:NSDate object
@property (nonatomic, readonly) NSMutableArray *messages;

videos

Array of text messages. The key is the userid and the value is JCGLVideoView.

@property (nonatomic, readonly) NSMutableDictionary *videos;

videoEnabled

Boolean whether the video is enabled or not. By default it is YES. You can disable the video by setting this variable to NO.

@property (nonatomic) BOOL videoEnabled;

audioEnabled

Boolean whether the video is enabled or not. By default it is YES. You can disable the audio by setting this variable to NO.

@property (nonatomic) BOOL audioEnabled;

turnIceServers

Override the default ICE servers. You should not have to change this.

@property (nonatomic, strong) NSArray *turnIceServers;

admin

Boolean that determines if the current user is an admin of ther room.

@property (nonatomic, readonly) BOOL admin;

locked

Boolean that determines if the current room is locked.

@property (nonatomic, readonly) BOOL locked;

Methods

initWithDelegate:options:

Initialization method.

- (id)initWithDelegate:(id<JCClientDelegate>)delegate options:(NSDictionary *)options;
delegate:

JCClientDelegate implementation

options:

NSDictionary containing options

  • apiKey - Set the API key
  • userid - Set userid. NSString representing the userid.
  • username - Set username. NSString representing the userid.
  • avatar - Set avatar. URL for the avatar. Can be base64 data url.
  • audioBandwidth - Set the audio bandwidth in kbps
  • videoBandwidth - Set the audio bandwidth in kbps

join:type:

Join a room.

- (void)join:(NSString *)room type:(NSString *)type;
room:

Name of the room.

type:

random or custom

  • Random rooms must have a length of 10.
  • Custom rooms must exist otherwise a disconnect message will be sent.

leave

Leave the room.

- (void)leave;

startBroadcasting

Start broadcasting audio and video. The delegate jc:videoAdded:view: will be called with me as the userid.

- (void)startBroadcasting;

stopBroadcasting

Stop broadcasting the audio and video. You don’t normally call this method.

- (void)stopBroadcasting;

changeCamera:

Change the camera from front to back.

- (void)changeCamera:(BOOL)front;
front:YES for front camera and NO for back camera.

sendTextMessage:

Send a text message to everyone in the room.

- (void)sendTextMessage:(NSString *)text;
text:Text message to broadcast

avatarForUserId:

Get the avatar for a given userid.

- (UIImage *)avatarForUserId:(NSString *)userid;
userid:User id string

usernameForUserId:

Get the username for a given userid.

- (NSString *)usernameForUserId:(NSString *)userid;
userid:User id string

lockRoom:

Lock the room. This will only work if you are an admin.

- (void)lockRoom:(BOOL)lock;
lock:YES to lock or NO to unlock.

kick:

Kick a user from the room.. This will only work if you are an admin.

- (void)kick:(NSString *)userid;
userid:User id string

knock:

Try to enter a room by knocking and give a message.

- (void)knock:(NSString *)msg;
msg:Message to the admin of the user

startCapturerer

Start the camera capturer. You do this when you are done with the camera. This will tell JCClient to gain access to the camera.

- (void)startCapturer;

stopCapturer

Stop the camera capturer. You do this when you need access to the camera. This will tell JCClient to release access to the camera.

- (void)stopCapturer;

muteVideo:state:

Mute a remote video stream.

- (void)muteVideo:(NSString *)userid state:(BOOL)state;
userid:User id string
state:YES to unmute or NO to mute

muteAudio:state:

Mute a remote audio stream.

- (void)muteAudio:(NSString *)userid state:(BOOL)state;
userid:User id string
state:YES to unmute or NO to mute