@100mslive/react-native-hms 1.9.8 → 1.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/android/local.properties +8 -1
- package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +2 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +98 -4
- package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +14 -7
- package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSInteractivityDecoder.kt +328 -0
- package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSInteractivityHelper.kt +352 -0
- package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSRNInteractivityCenter.kt +184 -0
- package/ios/HMSConstants.swift +1 -0
- package/ios/HMSDecoder.swift +3 -1
- package/ios/HMSInteractivityDecoder.swift +223 -0
- package/ios/HMSInteractivityHelper.swift +169 -0
- package/ios/HMSManager.m +17 -0
- package/ios/HMSManager.swift +30 -1
- package/ios/HMSRNInteractivityCenter.swift +89 -0
- package/ios/HMSRNSDK.swift +10 -4
- package/ios/Hmssdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcuserdata/jatinnagar.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Hmssdk.xcodeproj/xcuserdata/jatinnagar.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/commonjs/classes/HMSInteractivityCenter.js +93 -0
- package/lib/commonjs/classes/HMSInteractivityCenter.js.map +1 -0
- package/lib/commonjs/classes/HMSInteractivityEncoder.js +33 -0
- package/lib/commonjs/classes/HMSInteractivityEncoder.js.map +1 -0
- package/lib/commonjs/classes/HMSPermissions.js +4 -0
- package/lib/commonjs/classes/HMSPermissions.js.map +1 -1
- package/lib/commonjs/classes/HMSPollsListenerActions.js +11 -0
- package/lib/commonjs/classes/HMSPollsListenerActions.js.map +1 -0
- package/lib/commonjs/classes/HMSSDK.js +8 -0
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/polls/HMSPoll.js +6 -0
- package/lib/commonjs/classes/polls/HMSPoll.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollCategory.js +12 -0
- package/lib/commonjs/classes/polls/HMSPollCategory.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollCreateParams.js +6 -0
- package/lib/commonjs/classes/polls/HMSPollCreateParams.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollQuestion.js +6 -0
- package/lib/commonjs/classes/polls/HMSPollQuestion.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionAnswer.js +2 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionAnswer.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionCreateParams.js +6 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionCreateParams.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionOption.js +2 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionOption.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionOptionCreateParams.js +6 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionOptionCreateParams.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionQuizOptionCreateParams.js +6 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionQuizOptionCreateParams.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionResponse.js +6 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionResponse.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionResponseCreateParams.js +6 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionResponseCreateParams.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionResponseResult.js +2 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionResponseResult.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionResult.js +2 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionResult.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionType.js +14 -0
- package/lib/commonjs/classes/polls/HMSPollQuestionType.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollResponsePeerInfo.js +2 -0
- package/lib/commonjs/classes/polls/HMSPollResponsePeerInfo.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollResult.js +6 -0
- package/lib/commonjs/classes/polls/HMSPollResult.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollState.js +13 -0
- package/lib/commonjs/classes/polls/HMSPollState.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollType.js +12 -0
- package/lib/commonjs/classes/polls/HMSPollType.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollUpdateType.js +13 -0
- package/lib/commonjs/classes/polls/HMSPollUpdateType.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollUserTrackingMode.js +13 -0
- package/lib/commonjs/classes/polls/HMSPollUserTrackingMode.js.map +1 -0
- package/lib/commonjs/hooks/polls.js +17 -0
- package/lib/commonjs/hooks/polls.js.map +1 -0
- package/lib/commonjs/index.js +68 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/stores/hms-interactivity-store.js +21 -0
- package/lib/commonjs/stores/hms-interactivity-store.js.map +1 -0
- package/lib/commonjs/stores/hms-polls-slice.js +19 -0
- package/lib/commonjs/stores/hms-polls-slice.js.map +1 -0
- package/lib/commonjs/stores/types.js.map +1 -1
- package/lib/commonjs/utils/emitter/EventEmitter.js +19 -0
- package/lib/commonjs/utils/emitter/EventEmitter.js.map +1 -1
- package/lib/commonjs/utils/windowController.js +30 -0
- package/lib/commonjs/utils/windowController.js.map +1 -0
- package/lib/module/classes/HMSInteractivityCenter.js +85 -0
- package/lib/module/classes/HMSInteractivityCenter.js.map +1 -0
- package/lib/module/classes/HMSInteractivityEncoder.js +26 -0
- package/lib/module/classes/HMSInteractivityEncoder.js.map +1 -0
- package/lib/module/classes/HMSPermissions.js +4 -0
- package/lib/module/classes/HMSPermissions.js.map +1 -1
- package/lib/module/classes/HMSPollsListenerActions.js +5 -0
- package/lib/module/classes/HMSPollsListenerActions.js.map +1 -0
- package/lib/module/classes/HMSSDK.js +8 -0
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/polls/HMSPoll.js +2 -0
- package/lib/module/classes/polls/HMSPoll.js.map +1 -0
- package/lib/module/classes/polls/HMSPollCategory.js +6 -0
- package/lib/module/classes/polls/HMSPollCategory.js.map +1 -0
- package/lib/module/classes/polls/HMSPollCreateParams.js +2 -0
- package/lib/module/classes/polls/HMSPollCreateParams.js.map +1 -0
- package/lib/module/classes/polls/HMSPollQuestion.js +2 -0
- package/lib/module/classes/polls/HMSPollQuestion.js.map +1 -0
- package/lib/module/classes/polls/HMSPollQuestionAnswer.js +2 -0
- package/lib/module/classes/polls/HMSPollQuestionAnswer.js.map +1 -0
- package/lib/module/classes/polls/HMSPollQuestionCreateParams.js +2 -0
- package/lib/module/classes/polls/HMSPollQuestionCreateParams.js.map +1 -0
- package/lib/module/classes/polls/HMSPollQuestionOption.js +2 -0
- package/lib/module/classes/polls/HMSPollQuestionOption.js.map +1 -0
- package/lib/module/classes/polls/HMSPollQuestionOptionCreateParams.js +2 -0
- package/lib/module/classes/polls/HMSPollQuestionOptionCreateParams.js.map +1 -0
- package/lib/module/classes/polls/HMSPollQuestionQuizOptionCreateParams.js +2 -0
- package/lib/module/classes/polls/HMSPollQuestionQuizOptionCreateParams.js.map +1 -0
- package/lib/module/classes/polls/HMSPollQuestionResponse.js +2 -0
- package/lib/module/classes/polls/HMSPollQuestionResponse.js.map +1 -0
- package/lib/module/classes/polls/HMSPollQuestionResponseCreateParams.js +2 -0
- package/lib/module/classes/polls/HMSPollQuestionResponseCreateParams.js.map +1 -0
- package/lib/module/classes/polls/HMSPollQuestionResponseResult.js +2 -0
- package/lib/module/classes/polls/HMSPollQuestionResponseResult.js.map +1 -0
- package/lib/module/classes/polls/HMSPollQuestionResult.js +2 -0
- package/lib/module/classes/polls/HMSPollQuestionResult.js.map +1 -0
- package/lib/module/classes/polls/HMSPollQuestionType.js +8 -0
- package/lib/module/classes/polls/HMSPollQuestionType.js.map +1 -0
- package/lib/module/classes/polls/HMSPollResponsePeerInfo.js +2 -0
- package/lib/module/classes/polls/HMSPollResponsePeerInfo.js.map +1 -0
- package/lib/module/classes/polls/HMSPollResult.js +2 -0
- package/lib/module/classes/polls/HMSPollResult.js.map +1 -0
- package/lib/module/classes/polls/HMSPollState.js +7 -0
- package/lib/module/classes/polls/HMSPollState.js.map +1 -0
- package/lib/module/classes/polls/HMSPollType.js +6 -0
- package/lib/module/classes/polls/HMSPollType.js.map +1 -0
- package/lib/module/classes/polls/HMSPollUpdateType.js +7 -0
- package/lib/module/classes/polls/HMSPollUpdateType.js.map +1 -0
- package/lib/module/classes/polls/HMSPollUserTrackingMode.js +7 -0
- package/lib/module/classes/polls/HMSPollUserTrackingMode.js.map +1 -0
- package/lib/module/hooks/polls.js +12 -0
- package/lib/module/hooks/polls.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/stores/hms-interactivity-store.js +15 -0
- package/lib/module/stores/hms-interactivity-store.js.map +1 -0
- package/lib/module/stores/hms-polls-slice.js +12 -0
- package/lib/module/stores/hms-polls-slice.js.map +1 -0
- package/lib/module/stores/types.js.map +1 -1
- package/lib/module/utils/emitter/EventEmitter.js +19 -0
- package/lib/module/utils/emitter/EventEmitter.js.map +1 -1
- package/lib/module/utils/windowController.js +22 -0
- package/lib/module/utils/windowController.js.map +1 -0
- package/lib/typescript/classes/HMSInteractivityCenter.d.ts +35 -0
- package/lib/typescript/classes/HMSInteractivityEncoder.d.ts +4 -0
- package/lib/typescript/classes/HMSPermissions.d.ts +4 -0
- package/lib/typescript/classes/HMSPollsListenerActions.d.ts +3 -0
- package/lib/typescript/classes/HMSSDK.d.ts +3 -0
- package/lib/typescript/classes/polls/HMSPoll.d.ts +81 -0
- package/lib/typescript/classes/polls/HMSPollCategory.d.ts +10 -0
- package/lib/typescript/classes/polls/HMSPollCreateParams.d.ts +6 -0
- package/lib/typescript/classes/polls/HMSPollQuestion.d.ts +61 -0
- package/lib/typescript/classes/polls/HMSPollQuestionAnswer.d.ts +17 -0
- package/lib/typescript/classes/polls/HMSPollQuestionCreateParams.d.ts +25 -0
- package/lib/typescript/classes/polls/HMSPollQuestionOption.d.ts +21 -0
- package/lib/typescript/classes/polls/HMSPollQuestionOptionCreateParams.d.ts +3 -0
- package/lib/typescript/classes/polls/HMSPollQuestionQuizOptionCreateParams.d.ts +4 -0
- package/lib/typescript/classes/polls/HMSPollQuestionResponse.d.ts +47 -0
- package/lib/typescript/classes/polls/HMSPollQuestionResponseCreateParams.d.ts +2 -0
- package/lib/typescript/classes/polls/HMSPollQuestionResponseResult.d.ts +17 -0
- package/lib/typescript/classes/polls/HMSPollQuestionResult.d.ts +29 -0
- package/lib/typescript/classes/polls/HMSPollQuestionType.d.ts +18 -0
- package/lib/typescript/classes/polls/HMSPollResponsePeerInfo.d.ts +21 -0
- package/lib/typescript/classes/polls/HMSPollResult.d.ts +22 -0
- package/lib/typescript/classes/polls/HMSPollState.d.ts +14 -0
- package/lib/typescript/classes/polls/HMSPollType.d.ts +4 -0
- package/lib/typescript/classes/polls/HMSPollUpdateType.d.ts +5 -0
- package/lib/typescript/classes/polls/HMSPollUserTrackingMode.d.ts +14 -0
- package/lib/typescript/hooks/polls.d.ts +3 -0
- package/lib/typescript/index.d.ts +9 -0
- package/lib/typescript/stores/hms-interactivity-store.d.ts +9 -0
- package/lib/typescript/stores/hms-polls-slice.d.ts +5 -0
- package/lib/typescript/stores/types.d.ts +6 -0
- package/lib/typescript/utils/emitter/EventEmitter.d.ts +7 -0
- package/lib/typescript/utils/windowController.d.ts +10 -0
- package/package.json +1 -1
- package/sdk-versions.json +2 -2
- package/src/classes/HMSInteractivityCenter.ts +126 -0
- package/src/classes/HMSInteractivityEncoder.ts +29 -0
- package/src/classes/HMSPermissions.ts +6 -0
- package/src/classes/HMSPollsListenerActions.ts +3 -0
- package/src/classes/HMSSDK.tsx +10 -0
- package/src/classes/polls/HMSPoll.ts +108 -0
- package/src/classes/polls/HMSPollCategory.ts +11 -0
- package/src/classes/polls/HMSPollCreateParams.ts +19 -0
- package/src/classes/polls/HMSPollQuestion.ts +92 -0
- package/src/classes/polls/HMSPollQuestionAnswer.ts +29 -0
- package/src/classes/polls/HMSPollQuestionCreateParams.ts +36 -0
- package/src/classes/polls/HMSPollQuestionOption.ts +24 -0
- package/src/classes/polls/HMSPollQuestionOptionCreateParams.ts +8 -0
- package/src/classes/polls/HMSPollQuestionQuizOptionCreateParams.ts +6 -0
- package/src/classes/polls/HMSPollQuestionResponse.ts +72 -0
- package/src/classes/polls/HMSPollQuestionResponseCreateParams.ts +6 -0
- package/src/classes/polls/HMSPollQuestionResponseResult.ts +19 -0
- package/src/classes/polls/HMSPollQuestionResult.ts +41 -0
- package/src/classes/polls/HMSPollQuestionType.ts +21 -0
- package/src/classes/polls/HMSPollResponsePeerInfo.ts +24 -0
- package/src/classes/polls/HMSPollResult.ts +26 -0
- package/src/classes/polls/HMSPollState.ts +16 -0
- package/src/classes/polls/HMSPollType.ts +4 -0
- package/src/classes/polls/HMSPollUpdateType.ts +5 -0
- package/src/classes/polls/HMSPollUserTrackingMode.ts +16 -0
- package/src/hooks/polls.ts +14 -0
- package/src/index.ts +10 -0
- package/src/stores/hms-interactivity-store.ts +18 -0
- package/src/stores/hms-polls-slice.ts +20 -0
- package/src/stores/types.ts +20 -3
- package/src/utils/emitter/EventEmitter.ts +26 -0
- package/src/utils/windowController.ts +23 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { EventEmitter } from '../utils';
|
|
2
|
+
import HMSManager from '../modules/HMSManagerModule';
|
|
3
|
+
import { HMSConstants } from './HMSConstants';
|
|
4
|
+
import { logger } from './HMSLogger';
|
|
5
|
+
import type { HMSPoll } from './polls/HMSPoll';
|
|
6
|
+
import type { HMSPollCreateParams } from './polls/HMSPollCreateParams';
|
|
7
|
+
import type { HMSPollUpdateType } from './polls/HMSPollUpdateType';
|
|
8
|
+
import { HMSPollsListenerActions } from './HMSPollsListenerActions';
|
|
9
|
+
import HMSNativeEventListener from './HMSNativeEventListener';
|
|
10
|
+
import type { HMSEventSubscription } from './HMSNativeEventEmitter';
|
|
11
|
+
import { HMSInteractivityEncoder } from './HMSInteractivityEncoder';
|
|
12
|
+
|
|
13
|
+
type PollUpdateListener = (data: {
|
|
14
|
+
updatedPoll: HMSPoll;
|
|
15
|
+
update: HMSPollUpdateType;
|
|
16
|
+
}) => void;
|
|
17
|
+
|
|
18
|
+
type PollQuestionResponseCreateParams = {
|
|
19
|
+
pollId: string;
|
|
20
|
+
pollQuestionIndex: number;
|
|
21
|
+
responses:
|
|
22
|
+
| {
|
|
23
|
+
text: string;
|
|
24
|
+
duration?: number;
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
options: number[];
|
|
28
|
+
duration?: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
let pollUpdateSubscription: null | HMSEventSubscription = null;
|
|
33
|
+
|
|
34
|
+
function registerPollUpdateListener(listener: PollUpdateListener) {
|
|
35
|
+
if (pollUpdateSubscription !== null) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
pollUpdateSubscription = HMSNativeEventListener.addListener(
|
|
39
|
+
HMSConstants.DEFAULT_SDK_ID,
|
|
40
|
+
HMSPollsListenerActions.ON_POLL_UPDATE,
|
|
41
|
+
listener
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function unregisterPollUpdateListener() {
|
|
46
|
+
if (pollUpdateSubscription === null) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
pollUpdateSubscription.remove();
|
|
50
|
+
pollUpdateSubscription = null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class HMSInteractivityCenter {
|
|
54
|
+
private _eventEmitter = new EventEmitter();
|
|
55
|
+
|
|
56
|
+
private _pollUpdateListener = (...args: Parameters<PollUpdateListener>) => {
|
|
57
|
+
const { updatedPoll, update } = args[0];
|
|
58
|
+
logger?.verbose('#Listener ON_POLL_UPDATE', {
|
|
59
|
+
update,
|
|
60
|
+
updatedPoll,
|
|
61
|
+
});
|
|
62
|
+
this._eventEmitter.emit(
|
|
63
|
+
HMSPollsListenerActions.ON_POLL_UPDATE,
|
|
64
|
+
HMSInteractivityEncoder.transformPoll(updatedPoll),
|
|
65
|
+
update
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
private _onAllPollUpdateListenerRemoved = () => {
|
|
70
|
+
unregisterPollUpdateListener();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
constructor() {
|
|
74
|
+
this._eventEmitter.registerOnAllListenersRemoved(
|
|
75
|
+
this._onAllPollUpdateListenerRemoved
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Adds a listener for poll updates
|
|
81
|
+
* @param listener - Callback to be called when a poll is updated
|
|
82
|
+
* @returns HMSEventSubscription
|
|
83
|
+
*/
|
|
84
|
+
addPollUpdateListener(
|
|
85
|
+
listener: (updatedPoll: HMSPoll, update: HMSPollUpdateType) => void
|
|
86
|
+
) {
|
|
87
|
+
registerPollUpdateListener(this._pollUpdateListener);
|
|
88
|
+
return this._eventEmitter.addListener(
|
|
89
|
+
HMSPollsListenerActions.ON_POLL_UPDATE,
|
|
90
|
+
listener,
|
|
91
|
+
null
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Starts a poll
|
|
97
|
+
*
|
|
98
|
+
* @param pollParams
|
|
99
|
+
*/
|
|
100
|
+
async startPoll(pollParams: HMSPollCreateParams) {
|
|
101
|
+
const data = {
|
|
102
|
+
...pollParams,
|
|
103
|
+
id: HMSConstants.DEFAULT_SDK_ID,
|
|
104
|
+
};
|
|
105
|
+
logger?.verbose('#Function startPoll', JSON.stringify(data));
|
|
106
|
+
return HMSManager.quickStartPoll(data);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async add(pollQuestionResponseParams: PollQuestionResponseCreateParams) {
|
|
110
|
+
const data = {
|
|
111
|
+
...pollQuestionResponseParams,
|
|
112
|
+
id: HMSConstants.DEFAULT_SDK_ID,
|
|
113
|
+
};
|
|
114
|
+
logger?.verbose('#Function add', JSON.stringify(data));
|
|
115
|
+
return HMSManager.addResponseOnPollQuestion(data);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async stop(pollId: string) {
|
|
119
|
+
const data = {
|
|
120
|
+
id: HMSConstants.DEFAULT_SDK_ID,
|
|
121
|
+
pollId,
|
|
122
|
+
};
|
|
123
|
+
logger?.verbose('#Function stop', JSON.stringify(data));
|
|
124
|
+
return HMSManager.stopPoll(data);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HMSPoll } from './polls/HMSPoll';
|
|
2
|
+
|
|
3
|
+
export class HMSInteractivityEncoder {
|
|
4
|
+
static transformPoll(poll: HMSPoll): HMSPoll {
|
|
5
|
+
if (poll.startedAt) {
|
|
6
|
+
const dateNum = parseInt(poll.startedAt as unknown as string);
|
|
7
|
+
|
|
8
|
+
if (isNaN(dateNum)) {
|
|
9
|
+
poll.startedAt = undefined;
|
|
10
|
+
} else {
|
|
11
|
+
poll.startedAt = new Date(dateNum);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (poll.stoppedAt) {
|
|
15
|
+
const dateNum = parseInt(poll.stoppedAt as unknown as string);
|
|
16
|
+
|
|
17
|
+
if (isNaN(dateNum)) {
|
|
18
|
+
poll.stoppedAt = undefined;
|
|
19
|
+
} else {
|
|
20
|
+
poll.stoppedAt = new Date(dateNum);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// poll.rolesThatCanVote: HMSRole[];
|
|
24
|
+
// poll.rolesThatCanViewResponses: HMSRole[];
|
|
25
|
+
// --- poll.questions: HMSPollQuestion[]
|
|
26
|
+
// --- poll.result: HMSPollResult
|
|
27
|
+
return poll;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -7,6 +7,8 @@ export class HMSPermissions {
|
|
|
7
7
|
browserRecording?: boolean;
|
|
8
8
|
hlsStreaming?: boolean;
|
|
9
9
|
rtmpStreaming?: boolean;
|
|
10
|
+
pollRead?: boolean;
|
|
11
|
+
pollWrite?: boolean;
|
|
10
12
|
|
|
11
13
|
constructor(params?: {
|
|
12
14
|
endRoom?: boolean;
|
|
@@ -17,6 +19,8 @@ export class HMSPermissions {
|
|
|
17
19
|
browserRecording?: boolean;
|
|
18
20
|
hlsStreaming?: boolean;
|
|
19
21
|
rtmpStreaming?: boolean;
|
|
22
|
+
pollRead?: boolean;
|
|
23
|
+
pollWrite?: boolean;
|
|
20
24
|
}) {
|
|
21
25
|
if (params) {
|
|
22
26
|
this.endRoom = params.endRoom;
|
|
@@ -27,6 +31,8 @@ export class HMSPermissions {
|
|
|
27
31
|
this.browserRecording = params.browserRecording;
|
|
28
32
|
this.hlsStreaming = params.hlsStreaming;
|
|
29
33
|
this.rtmpStreaming = params.rtmpStreaming;
|
|
34
|
+
this.pollRead = params.pollRead;
|
|
35
|
+
this.pollWrite = params.pollWrite;
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
}
|
package/src/classes/HMSSDK.tsx
CHANGED
|
@@ -46,6 +46,7 @@ import { HMSSessionStore } from './HMSSessionStore';
|
|
|
46
46
|
import type { HMSPeerListIteratorOptions } from './HMSPeerListIteratorOptions';
|
|
47
47
|
import { HMSPeerListIterator } from './HMSPeerListIterator';
|
|
48
48
|
import type { HMSPIPConfig } from './HMSPIPConfig';
|
|
49
|
+
import { HMSInteractivityCenter } from './HMSInteractivityCenter';
|
|
49
50
|
|
|
50
51
|
type HmsViewProps = Omit<HmsComponentProps, 'id'>;
|
|
51
52
|
|
|
@@ -55,6 +56,8 @@ let HmsSdk: HMSSDK | undefined;
|
|
|
55
56
|
|
|
56
57
|
export class HMSSDK {
|
|
57
58
|
id: string;
|
|
59
|
+
private _interactivityCenter: HMSInteractivityCenter | null = null;
|
|
60
|
+
|
|
58
61
|
private appStateSubscription?: any;
|
|
59
62
|
private onPreviewDelegate?: any;
|
|
60
63
|
private onJoinDelegate?: any;
|
|
@@ -2491,6 +2494,13 @@ export class HMSSDK {
|
|
|
2491
2494
|
});
|
|
2492
2495
|
}
|
|
2493
2496
|
|
|
2497
|
+
get interactivityCenter() {
|
|
2498
|
+
if (!this._interactivityCenter) {
|
|
2499
|
+
this._interactivityCenter = new HMSInteractivityCenter();
|
|
2500
|
+
}
|
|
2501
|
+
return this._interactivityCenter;
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2494
2504
|
/**
|
|
2495
2505
|
* - Returns the instance of logger which can be used to manipulate log levels.
|
|
2496
2506
|
* @returns @instance HMSLogger
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { HMSPollState } from './HMSPollState';
|
|
2
|
+
import type { HMSPollQuestion } from './HMSPollQuestion';
|
|
3
|
+
import type { HMSPollResult } from './HMSPollResult';
|
|
4
|
+
import type { HMSRole } from '../HMSRole';
|
|
5
|
+
import type { HMSPollUserTrackingMode } from './HMSPollUserTrackingMode';
|
|
6
|
+
import type { HMSPollType } from './HMSPollType';
|
|
7
|
+
import type { HMSPeer } from '../HMSPeer';
|
|
8
|
+
|
|
9
|
+
type HMSPeerSubset = {
|
|
10
|
+
peerID: HMSPeer['peerID'];
|
|
11
|
+
name: HMSPeer['name'];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type HMSRoleSubset = {
|
|
15
|
+
name: HMSRole['name'];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export interface HMSPoll {
|
|
19
|
+
/**
|
|
20
|
+
The unique identifier of the poll.
|
|
21
|
+
*/
|
|
22
|
+
pollId: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
The title of the poll.
|
|
26
|
+
*/
|
|
27
|
+
title: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
The duration of the poll in seconds.
|
|
31
|
+
*/
|
|
32
|
+
duration?: number;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
A flag indicating whether the poll is anonymous or not.
|
|
36
|
+
*/
|
|
37
|
+
anonymous?: boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
The tracking mode for user participation in the poll.
|
|
41
|
+
*/
|
|
42
|
+
mode?: HMSPollUserTrackingMode;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
The roles that can vote in the poll.
|
|
46
|
+
*/
|
|
47
|
+
rolesThatCanVote?: HMSRoleSubset[];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
The roles that can view the poll responses.
|
|
51
|
+
*/
|
|
52
|
+
rolesThatCanViewResponses?: HMSRoleSubset[];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
The peer who started the poll.
|
|
56
|
+
*/
|
|
57
|
+
startedBy?: HMSPeerSubset;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
The peer who stopped the poll.
|
|
61
|
+
*/
|
|
62
|
+
stoppedBy?: HMSPeerSubset;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
The peer who created the poll.
|
|
66
|
+
*/
|
|
67
|
+
createdBy?: HMSPeerSubset;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
The date and time when the poll was started.
|
|
71
|
+
*/
|
|
72
|
+
startedAt?: Date;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
The date and time when the poll was stopped.
|
|
76
|
+
*/
|
|
77
|
+
stoppedAt?: Date;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
The type of the poll.
|
|
81
|
+
*/
|
|
82
|
+
type: HMSPollType;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
The current state of the poll.
|
|
86
|
+
*/
|
|
87
|
+
state?: HMSPollState;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
The list of questions in the poll.
|
|
91
|
+
*/
|
|
92
|
+
questions?: HMSPollQuestion[];
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
The result of the poll.
|
|
96
|
+
*/
|
|
97
|
+
result?: HMSPollResult;
|
|
98
|
+
|
|
99
|
+
// /**
|
|
100
|
+
// The visiblity of the poll. (Not available on iOS)
|
|
101
|
+
// */
|
|
102
|
+
// visibility?: boolean;
|
|
103
|
+
|
|
104
|
+
// /**
|
|
105
|
+
// * Is poll locked currently? (Not available on iOS)
|
|
106
|
+
// */
|
|
107
|
+
// locked?: boolean;
|
|
108
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HMSPoll } from './HMSPoll';
|
|
2
|
+
import type { HMSPollQuestionCreateParams } from './HMSPollQuestionCreateParams';
|
|
3
|
+
|
|
4
|
+
export interface HMSPollCreateParams
|
|
5
|
+
extends Pick<
|
|
6
|
+
HMSPoll,
|
|
7
|
+
| 'title'
|
|
8
|
+
| 'type'
|
|
9
|
+
| 'duration'
|
|
10
|
+
| 'anonymous'
|
|
11
|
+
// | 'visibility'
|
|
12
|
+
// | 'locked'
|
|
13
|
+
| 'mode'
|
|
14
|
+
| 'rolesThatCanVote'
|
|
15
|
+
| 'rolesThatCanViewResponses'
|
|
16
|
+
> {
|
|
17
|
+
pollId?: HMSPoll['pollId'];
|
|
18
|
+
questions?: HMSPollQuestionCreateParams[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { HMSPollQuestionAnswer } from './HMSPollQuestionAnswer';
|
|
2
|
+
import type { HMSPollQuestionOption } from './HMSPollQuestionOption';
|
|
3
|
+
import type { HMSPollQuestionResponse } from './HMSPollQuestionResponse';
|
|
4
|
+
import type { HMSPollQuestionType } from './HMSPollQuestionType';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
Represents a question in a poll.
|
|
8
|
+
*/
|
|
9
|
+
export interface HMSPollQuestion {
|
|
10
|
+
/**
|
|
11
|
+
The index of the question within the poll.
|
|
12
|
+
*/
|
|
13
|
+
index: number;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
The text of the question.
|
|
17
|
+
*/
|
|
18
|
+
text: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
A flag indicating whether the question is skippable or not.
|
|
22
|
+
*/
|
|
23
|
+
skippable: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
The duration hint of the question in seconds. Can be used for setting a timeframe withing which a question can be responded to. Not enforced by the server.
|
|
27
|
+
*/
|
|
28
|
+
duration: number;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
A flag indicating whether the question can be answered only once.
|
|
32
|
+
*/
|
|
33
|
+
once: boolean;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
The weight of the question in scoring.
|
|
37
|
+
*/
|
|
38
|
+
weight: number;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
The minimum length of the answer (if applicable).
|
|
42
|
+
*/
|
|
43
|
+
answerMinLen?: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
The maximum length of the answer (if applicable).
|
|
47
|
+
*/
|
|
48
|
+
answerMaxLen?: number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
The type of the question.
|
|
52
|
+
*/
|
|
53
|
+
type: HMSPollQuestionType;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
The list of options for the question (if applicable).
|
|
57
|
+
*/
|
|
58
|
+
options?: HMSPollQuestionOption[];
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
The answer for the question (if it is a quiz).
|
|
62
|
+
*/
|
|
63
|
+
answer?: HMSPollQuestionAnswer;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
The list of responses for the question.
|
|
67
|
+
*/
|
|
68
|
+
responses?: HMSPollQuestionResponse[];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
The responses provided by the current user for the question.
|
|
72
|
+
*/
|
|
73
|
+
myResponses: HMSPollQuestionResponse[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Web Inteface -
|
|
77
|
+
// export interface HMSPollQuestion {
|
|
78
|
+
// index: number;
|
|
79
|
+
// text: string;
|
|
80
|
+
// type: HMSPollQuestionType;
|
|
81
|
+
// skippable?: boolean;
|
|
82
|
+
// duration?: number;
|
|
83
|
+
// once?: boolean;
|
|
84
|
+
// weight?: number;
|
|
85
|
+
// negative?: boolean;
|
|
86
|
+
// answerMinLen?: number;
|
|
87
|
+
// answerMaxLen?: number;
|
|
88
|
+
// options?: HMSPollQuestionOption[];
|
|
89
|
+
// answer?: HMSPollQuestionAnswer;
|
|
90
|
+
// responses?: HMSPollQuestionResponse[];
|
|
91
|
+
// result?: HMSPollQuestionResult;
|
|
92
|
+
// }
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Provides the correct answer for a quiz question to check users' responses against.
|
|
3
|
+
*/
|
|
4
|
+
export interface HMSPollQuestionAnswer {
|
|
5
|
+
/**
|
|
6
|
+
A flag indicating whether the answer should be hidden or not.
|
|
7
|
+
*/
|
|
8
|
+
hidden: boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
The index of the selected option (in case of single choice question).
|
|
12
|
+
*/
|
|
13
|
+
option?: number;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
The list of indexes of selected options (in case of multiple choice question).
|
|
17
|
+
*/
|
|
18
|
+
options?: number[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Web Inteface -
|
|
22
|
+
// export interface HMSPollQuestionAnswer {
|
|
23
|
+
// hidden: boolean; // if true answer will not be returned when poll is running
|
|
24
|
+
// option?: number; // option index for correct answer, in case of single choice
|
|
25
|
+
// options?: number[]; // list of options that shoould be in answer
|
|
26
|
+
// text?: string; // answer text for answer.
|
|
27
|
+
// case?: boolean; // if false case is ignored when comparing.
|
|
28
|
+
// trim?: boolean; // if true, empty space is trimmer from start and end of asnwer.
|
|
29
|
+
// }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HMSPollQuestion } from './HMSPollQuestion';
|
|
2
|
+
import type { HMSPollQuestionOptionCreateParams } from './HMSPollQuestionOptionCreateParams';
|
|
3
|
+
import type { HMSPollQuestionQuizOptionCreateParams } from './HMSPollQuestionQuizOptionCreateParams';
|
|
4
|
+
|
|
5
|
+
export interface HMSPollQuestionCreateParams
|
|
6
|
+
extends Pick<
|
|
7
|
+
HMSPollQuestion,
|
|
8
|
+
'text' | 'skippable' | 'type' | 'answerMinLen' | 'answerMaxLen'
|
|
9
|
+
> {
|
|
10
|
+
/**
|
|
11
|
+
* A flag indicating whether the question can be answered only once.
|
|
12
|
+
*/
|
|
13
|
+
once?: HMSPollQuestion['once'];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The duration hint of the question in seconds. Can be used for setting a timeframe withing which a question can be responded to. Not enforced by the server.
|
|
17
|
+
*/
|
|
18
|
+
duration?: HMSPollQuestion['duration'];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The index of the question within the poll.
|
|
22
|
+
*/
|
|
23
|
+
index?: HMSPollQuestion['index'];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The options of the question.
|
|
27
|
+
*/
|
|
28
|
+
options?:
|
|
29
|
+
| HMSPollQuestionOptionCreateParams[]
|
|
30
|
+
| HMSPollQuestionQuizOptionCreateParams[];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The weight of the question in scoring.
|
|
34
|
+
*/
|
|
35
|
+
weight?: number;
|
|
36
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Represents an option for a poll question.
|
|
3
|
+
*/
|
|
4
|
+
export interface HMSPollQuestionOption {
|
|
5
|
+
/**
|
|
6
|
+
The index of the option within the question.
|
|
7
|
+
*/
|
|
8
|
+
index: number;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
The text of the option.
|
|
12
|
+
*/
|
|
13
|
+
text: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
The weight of the option in scoring.
|
|
17
|
+
*/
|
|
18
|
+
weight: number; // (optional on web)
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
The count of votes received for the option. `0` is the default value.
|
|
22
|
+
*/
|
|
23
|
+
voteCount: number; // (optional on web)
|
|
24
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { HMSPollQuestionType } from './HMSPollQuestionType';
|
|
2
|
+
import type { HMSPollResponsePeerInfo } from './HMSPollResponsePeerInfo';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
Represents a response for a poll question.
|
|
6
|
+
*/
|
|
7
|
+
export interface HMSPollQuestionResponse {
|
|
8
|
+
/**
|
|
9
|
+
The ID of the question associated with the response.
|
|
10
|
+
*/
|
|
11
|
+
questionID: number;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
The type of the question associated with the response.
|
|
15
|
+
*/
|
|
16
|
+
type: HMSPollQuestionType;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
A flag indicating whether the question was skipped or not.
|
|
20
|
+
*/
|
|
21
|
+
skipped: boolean;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
The index of the selected option (in case of single choice question).
|
|
25
|
+
*/
|
|
26
|
+
option: number;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
The list of indexes of selected options (in case of multiple choice question).
|
|
30
|
+
*/
|
|
31
|
+
options?: number[];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
The text answer provided (in case of short/long answer question).
|
|
35
|
+
*/
|
|
36
|
+
text: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
A flag indicating whether the response was updated from previous response.
|
|
40
|
+
*/
|
|
41
|
+
update: boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
Time taken to respond.
|
|
45
|
+
*/
|
|
46
|
+
duration: number;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
The peer information associated with the response. Depends on the tracking type selected for poll.
|
|
50
|
+
*/
|
|
51
|
+
peer?: HMSPollResponsePeerInfo;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
A flag indicating whether the response is final in case multiple responses were sent for this question.
|
|
55
|
+
*/
|
|
56
|
+
responseFinal?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Web Interface -
|
|
60
|
+
// export interface HMSPollQuestionResponse {
|
|
61
|
+
// id?: string;
|
|
62
|
+
// questionIndex: number;
|
|
63
|
+
// peer?: HMSPollResponsePeerInfo;
|
|
64
|
+
// type?: HMSPollQuestionType;
|
|
65
|
+
// skipped?: boolean;
|
|
66
|
+
// option?: number;
|
|
67
|
+
// options?: number[];
|
|
68
|
+
// text?: string;
|
|
69
|
+
// update?: boolean; // SDK Needs to track whether we previously answered and set accordingly
|
|
70
|
+
// duration?: number; // Time it took to answer the question for leaderboard
|
|
71
|
+
// responseFinal?: boolean; // Indicates whether this is last update when fetching responses
|
|
72
|
+
// }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the result of a poll question response.
|
|
3
|
+
*/
|
|
4
|
+
export interface HMSPollQuestionResponse {
|
|
5
|
+
/**
|
|
6
|
+
* The ID of the question associated with the response result.
|
|
7
|
+
*/
|
|
8
|
+
question: number;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A flag indicating whether the response was correct or not in case of quiz.
|
|
12
|
+
*/
|
|
13
|
+
correct?: boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An error associated with the response result (if any).
|
|
17
|
+
*/
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|