Skip to content

Commit

Permalink
Merge pull request #301 from 100mslive/develop
Browse files Browse the repository at this point in the history
Develop to main
  • Loading branch information
lavi-moolchandani committed Nov 3, 2021
2 parents 24a469b + fb29fcc commit 3026f3b
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ android/keystores/debug.keystore

# generated by bob
lib/
.project
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // From node_modules
implementation 'com.github.100mslive:android-sdk:v2.1.6'
implementation 'com.github.100mslive:android-sdk:2.1.8'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
}
19 changes: 15 additions & 4 deletions android/src/main/java/com/reactnativehmssdk/HmsModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,13 @@ class HmsModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
}
}
)
}catch (e: Exception){
}catch (e: HMSException){
val error: WritableMap = Arguments.createMap()
error.putString("message",e.localizedMessage)
error.putInt("code",e.code)
reactApplicationContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
.emit("ON_ERROR", e)
.emit("ON_ERROR", error)
}

hmsSDK?.addAudioObserver(
Expand Down Expand Up @@ -335,6 +338,10 @@ class HmsModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
arrayOf(Pair("message", "String"), Pair("roles", "Array"))
)
if (requiredKeys) {
val type =
if (HmsHelper.areAllRequiredKeysAvailable(data, arrayOf(Pair("type", "String"))))
data.getString("type")
else "chat"
val message = data.getString("message")
val targetedRoles = data.getArray("roles")?.toArrayList() as? ArrayList<String>
val roles = hmsSDK?.getRoles()
Expand All @@ -343,7 +350,7 @@ class HmsModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
if (message != null) {
hmsSDK?.sendGroupMessage(
message,
"chat",
type as String,
encodedTargetedRoles,
object : HMSMessageResultListener {
override fun onError(error: HMSException) {}
Expand All @@ -362,14 +369,18 @@ class HmsModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
arrayOf(Pair("message", "String"), Pair("peerId", "String"))
)
if (requiredKeys) {
val type =
if (HmsHelper.areAllRequiredKeysAvailable(data, arrayOf(Pair("type", "String"))))
data.getString("type")
else "chat"
val message = data.getString("message")
val peerId = data.getString("peerId")
val peers = hmsSDK?.getPeers()
val peer = HmsHelper.getPeerFromPeerId(peerId, peers)
if (message != null && peer != null) {
hmsSDK?.sendDirectMessage(
message,
"chat",
type as String,
peer,
object : HMSMessageResultListener {
override fun onError(error: HMSException) {}
Expand Down
22 changes: 18 additions & 4 deletions documentation/release-notes/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,43 @@ title: Release Notes
nav: 4.1
---

## 0.7.4 - 2021-11-03
- Catching exception on join function
- Cleared iOS global variables on leave
- Removed listeners on leave
- Exposed type param in message functions


## 0.7.3 - 2021-10-29
- Clearing local cache data when leaving a room
- Catching exceptions thrown by join function
- Added Role-based permissions checks


## 0.7.2 - 2021-10-28
- Added isPlaybackAllowed to remote audio & video tracks to mute/unmute remote tracks locally
- Added changeTrackState API to mute/unmute remote peers audio/video tracks for the entire room


## 0.7.1 - 2021-10-27
- Added mirror prop to HMSView to horizontally flip video tracks


## 0.7.0 - 2021-10-22
- Added audio level, peer & track object to HMSSpeaker
- Made package backwards compatible upto React Native version 0.63.0
- Removed Xcode 13 requirement
- Updated Sample app


## 0.6.0 - 2021-10-15
- Added aspect ratio prop to HMSView
- Asking for Camera & Microphone permissions only when required
- Updated video tiles aspect ratio
- Added horizontal pagination in sample app to improve performance

## 0.5.0 - 2021-09-29

## 0.5.0 - 2021-09-29
- Added Role-based permissions
- You can now Change the Role of Remote Peers
- Change Role of yourself
Expand All @@ -32,18 +48,16 @@ nav: 4.1


## 0.3.0 - 2021-08-31

- Updated to "react-native": "0.65.1" to mitigate security vulnerabilities
- Example App updated
- Multiple bug fixes & performance improvements


## 0.2.0 - 2021-08-18

- Added Support for Android! 🥳

## 0.1.0 - 2021-08-09

## 0.1.0 - 2021-08-09
The first version of 100ms React Native SDK comes power-packed with support for multiple features like -

- Join/Leave Rooms
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ android {
applicationId "live.hms.rn"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 14
versionName "1.0.14"
versionCode 15
versionName "1.0.15"
}
splits {
abi {
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ PODS:
- React-jsi (= 0.64.1)
- React-perflogger (= 0.64.1)
- React-jsinspector (0.64.1)
- react-native-hms (0.7.2):
- react-native-hms (0.7.4):
- HMSSDK
- React-Core
- react-native-safe-area-context (3.3.2):
Expand Down Expand Up @@ -661,7 +661,7 @@ SPEC CHECKSUMS:
React-jsi: 5de8204706bd872b78ea646aee5d2561ca1214b6
React-jsiexecutor: 124e8f99992490d0d13e0649d950d3e1aae06fe9
React-jsinspector: 500a59626037be5b3b3d89c5151bc3baa9abf1a9
react-native-hms: 616d1c87f90b4912c009f58ae21da20c2f801323
react-native-hms: cad209d468bff279820e77c59f87efe80ce59487
react-native-safe-area-context: 584dc04881deb49474363f3be89e4ca0e854c057
React-perflogger: aad6d4b4a267936b3667260d1f649b6f6069a675
React-RCTActionSheet: fc376be462c9c8d6ad82c0905442fd77f82a9d2a
Expand Down
8 changes: 4 additions & 4 deletions example/ios/RNHMSExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = RNHMSExample/RNHMSExample.entitlements;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 25;
DEVELOPMENT_TEAM = 5N85PP82A9;
ENABLE_BITCODE = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
Expand All @@ -542,7 +542,7 @@
"$(inherited)",
"$(SDKROOT)/usr/lib/swift",
);
MARKETING_VERSION = 1.14.0;
MARKETING_VERSION = 1.15.0;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -565,7 +565,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = RNHMSExample/RNHMSExample.entitlements;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 25;
DEVELOPMENT_TEAM = 5N85PP82A9;
ENABLE_BITCODE = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
Expand All @@ -579,7 +579,7 @@
"$(inherited)",
"$(SDKROOT)/usr/lib/swift",
);
MARKETING_VERSION = 1.14.0;
MARKETING_VERSION = 1.15.0;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
15 changes: 8 additions & 7 deletions ios/HmsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ class HmsManager: RCTEventEmitter, HMSUpdateListener, HMSPreviewListener {

@objc
func leave() {
DispatchQueue.main.async { [weak self] in
DispatchQueue.main.async { [weak self] in
self?.config = nil
self?.recentRoleChangeRequest = nil
self?.recentChangeTrackStateRequest = nil
self?.hms?.leave();
}
}
Expand All @@ -141,9 +144,7 @@ class HmsManager: RCTEventEmitter, HMSUpdateListener, HMSPreviewListener {
else {
return
}

let type = data.value(forKey: "type") as? String ?? "chat"

DispatchQueue.main.async { [weak self] in
self?.hms?.sendBroadcastMessage(type: type, message: message)
}
Expand All @@ -156,10 +157,10 @@ class HmsManager: RCTEventEmitter, HMSUpdateListener, HMSPreviewListener {
else {
return
}

let type = data.value(forKey: "type") as? String ?? "chat"
DispatchQueue.main.async { [weak self] in
let encodedTargetedRoles = HmsHelper.getRolesFromRoleNames(targetedRoles, roles: self?.hms?.roles)
self?.hms?.sendGroupMessage(message: message, roles: encodedTargetedRoles)
self?.hms?.sendGroupMessage(type: type, message: message, roles: encodedTargetedRoles)
}
}

Expand All @@ -170,10 +171,10 @@ class HmsManager: RCTEventEmitter, HMSUpdateListener, HMSPreviewListener {
else {
return
}

let type = data.value(forKey: "type") as? String ?? "chat"
DispatchQueue.main.async { [weak self] in
guard let peer = HmsHelper.getPeerFromPeerId(peerId, remotePeers: self?.hms?.remotePeers) else { return }
self?.hms?.sendDirectMessage(message: message, peer: peer)
self?.hms?.sendDirectMessage(type: type, message: message, peer: peer)
}
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@100mslive/react-native-hms",
"version": "0.7.3",
"version": "0.7.4",
"description": "The React Native package for 100ms SDK",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
73 changes: 69 additions & 4 deletions src/classes/HMSSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,68 @@ export class HMSSDK {
);
};

removeListeners = () => {
HmsEventEmitter.removeListener(
HMSUpdateListenerActions.ON_JOIN,
this.onJoinListener
);

HmsEventEmitter.removeListener(
HMSUpdateListenerActions.ON_ROOM_UPDATE,
this.onRoomListener
);

HmsEventEmitter.removeListener(
HMSUpdateListenerActions.ON_PEER_UPDATE,
this.onPeerListener
);

HmsEventEmitter.removeListener(
HMSUpdateListenerActions.ON_TRACK_UPDATE,
this.onTrackListener
);

HmsEventEmitter.removeListener(
HMSUpdateListenerActions.ON_ERROR,
this.onErrorListener
);

HmsEventEmitter.removeListener(
HMSUpdateListenerActions.ON_MESSAGE,
this.onMessageListener
);

HmsEventEmitter.removeListener(
HMSUpdateListenerActions.ON_SPEAKER,
this.onSpeakerListener
);

HmsEventEmitter.removeListener(
HMSUpdateListenerActions.RECONNECTING,
this.reconnectingListener
);

HmsEventEmitter.removeListener(
HMSUpdateListenerActions.RECONNECTED,
this.reconnectedListener
);

HmsEventEmitter.removeListener(
HMSUpdateListenerActions.ON_ROLE_CHANGE_REQUEST,
this.onRoleChangeRequestListener
);

HmsEventEmitter.removeListener(
HMSUpdateListenerActions.ON_CHANGE_TRACK_STATE_REQUEST,
this.onChangeTrackStateRequestListener
);

HmsEventEmitter.removeListener(
HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM,
this.onRemovedFromRoomListener
);
};

/**
* takes an instance of [HMSConfig]{@link HMSConfig} and joins the room
* after joining the room user will start receiving the events and updates of the room
Expand Down Expand Up @@ -159,27 +221,30 @@ export class HMSSDK {
this.remotePeers = undefined;
this.room = undefined;
this.knownRoles = undefined;
this.removeListeners();
HmsManager.leave();
};

sendBroadcastMessage = (message: string) => {
sendBroadcastMessage = (message: string, type?: string) => {
this.logger?.verbose('SEND_BROADCAST_MESSAGE', { message });
HmsManager.sendBroadcastMessage({ message });
HmsManager.sendBroadcastMessage({ message, type: type || null });
};

sendGroupMessage = (message: string, roles: HMSRole[]) => {
sendGroupMessage = (message: string, roles: HMSRole[], type?: string) => {
this.logger?.verbose('SEND_GROUP_MESSAGE', { message, roles });
HmsManager.sendGroupMessage({
message,
roles: HMSHelper.getRoleNames(roles),
type: type || null,
});
};

sendDirectMessage = (message: string, peerId: string) => {
sendDirectMessage = (message: string, peerId: string, type?: string) => {
this.logger?.verbose('SEND_DIRECT_MESSAGE', { message, peerId });
HmsManager.sendDirectMessage({
message,
peerId,
type: type || null,
});
};

Expand Down

0 comments on commit 3026f3b

Please sign in to comment.