Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to event listeners #157

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

pmogollons
Copy link
Contributor

  • Moved listeners to a separate file
  • Changed listener event names
  • Send what the event receives to RN
  • Implemented new listeners

This PR is just a draft to start working on the new events, there are still some questions and things to be discussed like:

  • Should events just send userId and we get the actual user in RN or should this events send the userId, user, and some other params like isSelf and other user info?
  • I have seen that in some cases the custom UI doesn't update when a user is unmuted, it keeps showing the muted icon beside the name, should we update the view on other listeners?
  • Is there really a need for multiple event "namespaces" AuthEvent and MeetingEvent, should it be better to just have one event that is less prone to collisions with other packages like ZoomUsEvent?
  • Should we send VideoStatus, AudioStatus, RecordingStatus, SharingStatus as int's or should we send it as Strings?
  • Should we send sourceType as int or as string?

* Moved listeners to a separate file
* Changed listener event names
* Send what the event receives to RN
* Implemented new listeners
Removed comment
Copy link
Owner

@mieszko4 mieszko4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got few notes inline
Also some general problems:

  1. it is very hard to track the changes since the entire pr is in one commit - use multiple commit, especially a single commit should be just for moving out events into the new file.
  2. all of these changes are breaking changes and I still think we should first agree on the event names and then do the new implementation, especially:
  • what event name pattern we will apply
  • if we will always use minimum event data with an idea of fetching the details by the user with helper functions (e.g. just send id of user and use getUserInfo in js callback)
  • what names we will use for the even data (userId is not clear what it means)

In the next comment I will write about my proposal of how to push this forward.

Comment on lines +579 to +581
// TODO: We should return the promise resolve
} else {
sendEvent("MeetingEvent", "screenShareError", result);
// TODO: We should return the promise rejection
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

*/
@Override
public void onHostAskUnMute(long userId) {
sendEvent("audio.host.unmute", userId);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions since we do it from scratch:

Suggested change
sendEvent("audio.host.unmute", userId);
// 1. always put it in object
WritableMap data = Arguments.createMap();
// 2. this allows to name the params intuitively
data.putDouble("requestorId", userId);
// or
data.putDouble("requesteeId", userId);
// (userId does not tell us if it is a requestor or requestee)
// 3. name event more specefically (unmute could mean that host unmuted itself
sendEvent("audio.host.unmuteRequested", data);

WritableMap data = Arguments.createMap();
data.putInt("type", type);

sendEvent("audio.self.type.changed", data);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you use host and self as the origin of the event triggering

Also I like the grouping, i.e. the first part of the event name.
I see the following event name pattern here:

[eventGroup].[originOfEventTrigger].[eventName]

Where:

  • eventGroup = audio, video, chat, ...
  • originOfEventTrigger = self, host, any, ...
  • eventName = noun with verb, e.g. typeChanged, unmuteRequested (if we agree that "unmute" is a noun)

We should always stick to the same agreed event name pattern (not necessarily this one)

🤔 I am just still not sure if it makes sense to name the events with such pattern...


@Override
public void onUserAudioStatusChanged(long userId, AudioStatus audioStatus) {
sendEvent("audio.status.changed", userId, audioStatus);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here status in the name is not the origin - so it is confusing.
I would do audio.self.statusChanged if we follow [eventGroup].[originOfEventTrigger].[eventName]

audio.status.changed follows another event name pattern of [eventGroup].[subject].[pastVerb].
The question is is it feasable to apply such pattern to all the events?


@Override
public void onMicrophoneStatusError(InMeetingAudioController.MobileRTCMicrophoneError error) {
sendEvent("audio.status.error", error);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 not sure how to fit "error" into the event name pattern.
There is a verb "to err" but that would look weird, i.e. "audio.status.erred" or "audio.self.statusErred"

@Override
public void onMyAudioSourceTypeChanged(int type) {
WritableMap data = Arguments.createMap();
data.putInt("type", type);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I agree to remove final InMeetingUserInfo userInfo, i.e. to keep the minimum number of params and then to expose helper methods (here we should expose getMyUserInfo)

  2. I think int that are used and are enum-like should be converted to enums, so it is easy to write code with typescript. type is an example here.

Comment on lines -967 to -987
public void onShareActiveUser(long userId) {
final InMeetingService inMeetingService = ZoomSDK.getInstance().getInMeetingService();

updateVideoView();

if (inMeetingService.isMyself(userId)) {
sendEvent("MeetingEvent", "screenShareStarted");

final InMeetingShareController shareController = inMeetingService.getInMeetingShareController();

if (shareController.isSharingOut()) {
if (shareController.isSharingScreen()) {
shareController.startShareScreenContent();
}
}
} else if (userId == 0) {
sendEvent("MeetingEvent", "screenShareStopped");
} else {
sendEvent("MeetingEvent", "screenShareStartedByUser", userId);
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that onShareActiveUser was removed but not copied. Why?

Comment on lines +342 to +364
private void sendEvent(String event, long userId, AudioStatus audioStatus) {
WritableMap data = Arguments.createMap();
data.putDouble("userId", userId);
data.putInt("audioStatus", AudioStatus.valueOf(audioStatus));

sendEvent(event, data);
}

private void sendEvent(String event, long userId, VideoStatus videoStatus) {
WritableMap data = Arguments.createMap();
data.putDouble("userId", userId);
data.putInt("videoStatus", VideoStatus.valueOf(videoStatus));

sendEvent(event, data);
}

private void sendEvent(String event, long userId, SharingStatus sharingStatus) {
WritableMap data = Arguments.createMap();
// https://marketplacefront.zoom.us/sdk/meeting/android/us/zoom/sdk/SharingStatus.html
data.putInt("sharingStatus", SharingStatus.valueOf(sharingStatus));

sendEvent(event, data);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 not sure if we need this. If we can have helper functions to access this info from code I think that userId should be enough... That would simplify the events

@mieszko4
Copy link
Owner

  • Moved listeners to a separate file
  • Changed listener event names
  • Send what the event receives to RN
  • Implemented new listeners

This PR is just a draft to start working on the new events, there are still some questions and things to be discussed like:

  • Should events just send userId and we get the actual user in RN or should this events send the userId, user, and some other params like isSelf and other user info?

I am for sending just userId and getting the actual user info in RN. I am just wondering if that will be possible for non-self user.

  • I have seen that in some cases the custom UI doesn't update when a user is unmuted, it keeps showing the muted icon beside the name, should we update the view on other listeners?

Not sure, but it should probably not be the focus of this refactoring

  • Is there really a need for multiple event "namespaces" AuthEvent and MeetingEvent, should it be better to just have one event that is less prone to collisions with other packages like ZoomUsEvent?

🤔 I agree - one event name should be enough. But there cannot be event name collisions with other libs, no? Each lib has its own app id. So event like video.self.statusChange is fine, i.e. no need for any prefixing if that's what you meant

  • Should we send VideoStatus, AudioStatus, RecordingStatus, SharingStatus as int's or should we send it as Strings?

I think it does not matter as long as from typescript we can access them with enums.
If there is inconsistency between ios and android then we could have a mapping, e.g. in index.ts (i.e. no need to have the mapping in native java/objective-c) so that when using the lib a programmer can use the same Enum.

  • Should we send sourceType as int or as string?

The same as above - it should be an enum in the end.

Since there are a lot of moving parts here, let's try keep it minimalistic/simple as much as possible - my proposal how to push things forwards:

  1. Make a new pr where the only thing would be moving the events into a separate listener file (non-breaking, easy to track changes).
  2. Create another listener file where we would add the new events that will not be documented so they can be easily changed until we are happy with the naming
  3. Document the new listener file and deprecate the old file
  4. After some time remove the deprecated events from the doc and the deprecated old file, too - release with major version

As for choosing the naming I would first start with finding a consistent event name pattern that would fit to all the events. I like the idea of grouping (video, audio, chat...) and I strive for the consistency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants