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

feat: raise-hand #19

Merged
merged 3 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/core/webrtc/webrtc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ class WaterbusWebRTCManagerIpml extends WaterbusWebRTCManager {
if (_mParticipant == null) return;

_mParticipant!.isHandRaising = !_mParticipant!.isHandRaising;

_notify(CallbackEvents.shouldBeUpdateState);

_socketEmiter.setHandRaising(_mParticipant!.isHandRaising);
}

Expand Down Expand Up @@ -525,8 +528,11 @@ class WaterbusWebRTCManagerIpml extends WaterbusWebRTCManager {

@override
void setHandRaising({required String targetId, required bool isRaising}) {
if (_subscribers[targetId]?.isHandRaising == isRaising) return;

_subscribers[targetId]?.isHandRaising = isRaising;
_notify(CallbackEvents.shouldBeUpdateState);

_notify(CallbackEvents.raiseHand);
}

@override
Expand Down
1 change: 0 additions & 1 deletion lib/core/websocket/socket_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ class SocketHandlerImpl extends SocketHandler {

final String participantId = data['participantId'];
final bool isRaising = data['isRaising'];

_rtcManager.setHandRaising(
targetId: participantId,
isRaising: isRaising,
Expand Down
4 changes: 4 additions & 0 deletions lib/flutter_waterbus_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ class WaterbusSdk {
await _sdk.toggleAudio();
}

void toggleRaiseHand() {
_sdk.toggleRaiseHand();
}

Future<void> toggleSpeakerPhone() async {
await _sdk.toggleSpeakerPhone();
}
Expand Down
1 change: 1 addition & 0 deletions lib/types/enums/callback_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ enum CallbackEvents {
newParticipant,
participantHasLeft,
shouldBeUpdateState,
raiseHand,
meetingEnded,
}
9 changes: 9 additions & 0 deletions lib/types/models/participant_sfu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ParticipantSFU extends Equatable {

return other.isVideoEnabled == isVideoEnabled &&
other.isAudioEnabled == isAudioEnabled &&
other.isHandRaising == isHandRaising &&
other.isSharingScreen == isSharingScreen &&
other.peerConnection == peerConnection &&
other.cameraSource == cameraSource &&
Expand All @@ -85,6 +86,7 @@ class ParticipantSFU extends Equatable {
int get hashCode {
return isVideoEnabled.hashCode ^
isAudioEnabled.hashCode ^
isHandRaising.hashCode ^
isSharingScreen.hashCode ^
peerConnection.hashCode ^
cameraSource.hashCode ^
Expand All @@ -96,6 +98,7 @@ class ParticipantSFU extends Equatable {
return [
isVideoEnabled,
isAudioEnabled,
isHandRaising,
isE2eeEnabled,
isSpeakerPhoneEnabled,
isSharingScreen,
Expand All @@ -110,6 +113,7 @@ class ParticipantSFU extends Equatable {
String? ownerId,
bool? isVideoEnabled,
bool? isAudioEnabled,
bool? isHandRaising,
bool? isE2eeEnabled,
bool? isSpeakerPhoneEnabled,
bool? isSharingScreen,
Expand All @@ -125,6 +129,7 @@ class ParticipantSFU extends Equatable {
ownerId: ownerId ?? this.ownerId,
isVideoEnabled: isVideoEnabled ?? this.isVideoEnabled,
isAudioEnabled: isAudioEnabled ?? this.isAudioEnabled,
isHandRaising: isHandRaising ?? this.isHandRaising,
isE2eeEnabled: isE2eeEnabled ?? this.isE2eeEnabled,
isSpeakerPhoneEnabled:
isSpeakerPhoneEnabled ?? this.isSpeakerPhoneEnabled,
Expand Down Expand Up @@ -192,6 +197,10 @@ extension ParticipantSFUX on ParticipantSFU {
}
}

Future<void> setHandRaising(bool isRaising) async {
isHandRaising = isRaising;
}

Future<void> dispose() async {
setScreenSharing(false);
cameraSource?.dispose();
Expand Down
5 changes: 5 additions & 0 deletions lib/waterbus_sdk_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ class SdkCore extends WaterbusSdkInterface {
await _rtcManager.toggleAudio();
}

@override
void toggleRaiseHand() {
_rtcManager.toggleRaiseHand();
}

@override
Future<void> toggleSpeakerPhone() async {
await _rtcManager.toggleSpeakerPhone();
Expand Down
2 changes: 2 additions & 0 deletions lib/waterbus_sdk_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ abstract class WaterbusSdkInterface {
Future<bool> stopRecord();
Future<void> leaveRoom();

void toggleRaiseHand();

// white board
Future<void> startWhiteBoard();
Future<void> updateWhiteBoard(
Expand Down
Loading