Netless

Netless

  • JavaScript
  • Android
  • iOS
  • Server
  • FAQ
  • GitHub
  • 🇨🇳 中文

›Quick start

Overview

  • Introduction
  • Open source
  • Version history

Quick start

  • Overview
  • Client integration
  • Init SDK
  • Create Room
  • Join room
  • Callback and lifecycle

Features

  • Docs-conversion & replay
  • State management
  • Tools
  • Perspective operation
  • Whiteboard operation
  • Custom event
  • Scene management
  • Big class read-only
  • Replay

Upgrade

  • 2.0 v2migration

Join room

After completing the operation of creating a room / obtaining a RoomToken for a specific room, and getting the room UUID and room RoomToken, the developer can call WhiteSDK`` joinRoom related APIs.

The related code in this article can be viewed in the WhiteRoomViewController of the Demo project.

Join the room

@import UIKit;
#import "WhiteBaseViewController.h"

@interface WhiteRoomViewController : WhiteBaseViewController

@property (nonatomic, strong, nullable) WhiteRoom *room;

#pragma mark - CallbackDelegate
@property (nonatomic, weak, nullable) id<WhiteRoomCallbackDelegate> roomCallbackDelegate;

@end

@implementation WhiteRoomViewController

- (void)joinRoomWithToken:(NSString *)roomToken
{
    self.title = NSLocalizedString(@"Connecting room", nil);
    
    WhiteRoomConfig *roomConfig = [[WhiteRoomConfig alloc] initWithUuid:self.roomUuid roomToken:roomToken memberInfo:memberInfo];
    
    [self.sdk joinRoomWithConfig:roomConfig callbacks:self.roomCallbackDelegate completionHandler:^(BOOL success, WhiteRoom * _Nonnull room, NSError * _Nonnull error) {
        if (success) {
            self.title = NSLocalizedString(@"My whiteboard", nil);
            self.room = room;
        } else {
            self.title = NSLocalizedString(@"Join failed", nil);
            UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Failed to join the room", nil) message:[NSString stringWithFormat:@"Error message:%@", [error localizedDescription]] preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"determine", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                [self.navigationController popViewControllerAnimated:YES];
            }];
            [alertVC addAction:action];
            [self presentViewController:alertVC animated:YES completion:nil];
        }
    }];
}

@end

Active disconnect room

After calling the active disconnect API, if you want to join the room again, you need to re-create the SDK instance to connect. Room uuid and room token can remain unchanged.

[self.room disconnect:^{
    // Disconnected successfully
}];

Effect

image.png | left | 488x850

Last updated on 1/14/2020 by 伍双
← Create RoomCallback and lifecycle →
  • Join the room
  • Active disconnect room
  • Effect
Netless
Let's interactive.
Product
ConsoleHomepageDemoGithub
Company
Join usServicePrivacy
Contact
support@netless.linkCommunity
Copyright © 2020 Netless