Git Product home page Git Product logo

wsmts's Introduction

WSMTS

Installation

Prerequisites

To use the WSMTS for iOS Swift and Objective-C, you need:

  • iOS 6.0 or later as the deployment target.
  • Xcode 11 or later.
  • WSMTS supports armv7, armv7s, arm64, i386 and x86_64 architectures.
  • WSMTS supports Bitcode.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate WSMTS into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'WSMTS', '1.0.1'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate WSMTS into your Xcode project using Carthage, specify it in your Cartfile:

github "17media/WSMTS" "1.0.1"

Mannually

  1. Add WSMTS.framework into your project.
  2. Add dependent library stdc++.
  3. Import header file #import <WSMTS/WSMTS.h>

Interface

Parameter

  1. Please refer WSMTS.h.
  2. Make sure you call initWithAppID before using SDK. This function creates a background thread to run the SDK.
  3. Call finish to release the SDK.
  4. Passing 0 into leaveRoomWithID would make WSMTS leave all rooms.

Demo

#import <WSMTS/WSMTS.h>
#import "ViewController.h"

@interface ViewController ()<WSMTSDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Initialize SDK
    BOOL result = [WSMTS initWithAppID:@"sdk.wekt.net" port:60000 appid:996];
    if (result) {
      	// Setup callback
      	[WSMTS setDelegate:delegate:self]
        // Enter room
        result = [WSMTS enterRoomWithID:1001 authority:@""];
        // Send barrage
        result = [WSMTS sendBarrageWithPriority:self.loginInfo.roomID message:messageData];
    }
}

#pragma - WSMTSDelegate

- (void)wsmtsConnectWithResult:(NSInteger)roomID result:(BOOL)result {
    NSString *msg = [NSString stringWithFormat:@"roomid: %ld connect result: %@", (long)roomID, result ? @"sucess" : @"failed"];
    [self displayMessage:msg];
    NSLog(@"%@", msg);
}

- (void)wsmtsDisconnectWithRoomID:(NSInteger)roomID {
    NSString *msg = [NSString stringWithFormat:@"disconnect roomid: %ld", (long)roomID];
    [self displayMessage:msg];
    NSLog(@"%@", msg);
}

- (void)wsmtsEnterRoom:(NSInteger)roomID withErrorCode:(NSInteger)errorCode {
    NSString *message;
    switch (errorCode) {
        case 0:
            message = @"sucess";
            break;
        case 1:
            message = @"get room network address failed";
            break;
        case 2:
            message = @"socket disconnect failed";
            break;
        case 3:
            message = @"authentication failed";
            break;
	case 4:
	    message = @"domain name parsing failed";
            break;
	case 5:
	    message = @"incorrect room ID";
            break;
        case 10:
            message = @"others error";
            break;
        default:
            message = @"unknown error";
            break;
    }
    NSString *msg = [NSString stringWithFormat:@"enter roomid: %ld, error code: %ld, description: %@", (long)roomID, (long)errorCode, message];
    [self displayMessage:msg];
    NSLog(@"%@", msg);

}

- (void)wsmtsReceiveBarrage:(NSInteger)roomID message:(NSData *)message {
    NSString *string = [[NSString alloc] initWithData:message encoding:NSUTF8StringEncoding];
    NSString *msg = [NSString stringWithFormat:@"room %ld receive barrage: %@", (long)roomID, string];
    [self displayMessage:msg];
    NSLog(@"%@", msg);
}

- (void)wsmtsReceivePrivateChatWithCID:(NSInteger)roomID cid:(NSString*)cid message:(NSData *)message {
    NSString *string = [[NSString alloc] initWithData:message encoding:NSUTF8StringEncoding];
    NSString *msg = [NSString stringWithFormat:@"room %ld receive private chat: %@, %@", (long)roomID, cid, string];
    [self displayMessage:msg];
    NSLog(@"%@", msg);
}

@end

wsmts's People

Contributors

racingwang avatar

Watchers

James Cloos avatar Sammy Lin avatar JT Yu avatar Zack avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.