Skip to content

Commit

Permalink
feat(meeting): map webrtc manager & socket handler
Browse files Browse the repository at this point in the history
  • Loading branch information
lambiengcode committed Oct 2, 2023
1 parent 5e44b61 commit 1535b64
Show file tree
Hide file tree
Showing 13 changed files with 469 additions and 130 deletions.
1 change: 1 addition & 0 deletions lib/core/constants/api_endpoints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ class ApiEndpoints {

// Meetings
static const String meetings = 'meetings';
static const String participants = 'meetings/participants';
}
4 changes: 2 additions & 2 deletions lib/core/constants/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const Map<String, dynamic> configurationWebRTC = {
},
{
"username":
"4rBa7ppl_U6p0eE5PZUrpQXRLWfn8ZZ1aglRQGlsReViBb_G_fbKp3P3IIW62N7RAAAAAGN18pZkaW5odHJvbmcwNTAz",
"credential": "f3d0dacc-6652-11ed-a6d5-0242ac120004",
"2PExpnKaMnfeEv-Q17l_AIzddJjcTYqYZBZG3P19ocYnPDpDaRo-HBkXfYhO7zQXAAAAAGUaT-BsYW1iaWVuZ2NvZGU=",
"credential": "78a9fdc6-60e1-11ee-9c54-0242ac120004",
"urls": [
"turn:hk-turn1.xirsys.com:80?transport=udp",
"turn:hk-turn1.xirsys.com:3478?transport=udp",
Expand Down
76 changes: 40 additions & 36 deletions lib/core/injection/injection_container.config.dart

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

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:waterbus/core/constants/api_endpoints.dart';
import 'package:waterbus/core/types/http_status_code.dart';
import 'package:waterbus/core/utils/datasources/base_remote_data.dart';
import 'package:waterbus/features/meeting/domain/entities/meeting.dart';
import 'package:waterbus/features/meeting/domain/entities/participant.dart';

abstract class MeetingRemoteDataSource {
Future<Meeting?> createMeeting({
Expand All @@ -26,6 +27,7 @@ abstract class MeetingRemoteDataSource {
required int code,
required int participantId,
});
Future<Participant?> getParticipant(int participantId);
}

@LazySingleton(as: MeetingRemoteDataSource)
Expand Down Expand Up @@ -129,4 +131,18 @@ class MeetingRemoteDataSourceImpl extends MeetingRemoteDataSource {

return false;
}

@override
Future<Participant?> getParticipant(int participantId) async {
final Response response = await _remoteData.getRoute(
'${ApiEndpoints.participants}/$participantId',
);

if (response.statusCode == StatusCode.ok) {
final Map<String, dynamic> rawData = response.data;
return Participant.fromMap(rawData['participant']);
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:waterbus/features/app/bloc/bloc.dart';
import 'package:waterbus/features/meeting/data/datasources/meeting_local_datasource.dart';
import 'package:waterbus/features/meeting/data/datasources/meeting_remote_datasource.dart';
import 'package:waterbus/features/meeting/domain/entities/meeting.dart';
import 'package:waterbus/features/meeting/domain/entities/participant.dart';
import 'package:waterbus/features/meeting/domain/repositories/meeting_repository.dart';
import 'package:waterbus/features/meeting/domain/usecases/create_meeting.dart';
import 'package:waterbus/features/meeting/domain/usecases/get_info_meeting.dart';
Expand Down Expand Up @@ -119,6 +120,20 @@ class MeetingRepositoryImpl extends MeetingRepository {
return const Right(true);
}

@override
Future<Either<Failure, Participant>> getParticipantById(
int participantId,
) async {
final Participant? participant = await _remoteDataSource.getParticipant(
participantId,
);

if (participant == null) return Left(NullValue());

return Right(participant);
}

// MARK: private
Meeting findMyParticipantObject(
Meeting meeting, {
int? participantId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:dartz/dartz.dart';
// Project imports:
import 'package:waterbus/core/error/failures.dart';
import 'package:waterbus/features/meeting/domain/entities/meeting.dart';
import 'package:waterbus/features/meeting/domain/entities/participant.dart';
import 'package:waterbus/features/meeting/domain/usecases/create_meeting.dart';
import 'package:waterbus/features/meeting/domain/usecases/get_info_meeting.dart';
import 'package:waterbus/features/meeting/domain/usecases/leave_meeting.dart';
Expand All @@ -16,4 +17,5 @@ abstract class MeetingRepository {
Future<Either<Failure, Meeting>> leaveMeeting(LeaveMeetingParams params);
Future<Either<Failure, Meeting>> getInfoMeeting(GetMeetingParams params);
Either<Failure, bool> cleanAllRecentJoined();
Future<Either<Failure, Participant>> getParticipantById(int participantId);
}
33 changes: 33 additions & 0 deletions lib/features/meeting/domain/usecases/get_participant.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Package imports:
import 'package:dartz/dartz.dart';
import 'package:equatable/equatable.dart';
import 'package:injectable/injectable.dart';

// Project imports:
import 'package:waterbus/core/error/failures.dart';
import 'package:waterbus/core/usecase/usecase.dart';
import 'package:waterbus/features/meeting/domain/entities/participant.dart';
import 'package:waterbus/features/meeting/domain/repositories/meeting_repository.dart';

@injectable
class GetParticipant implements UseCase<Participant, GetPariticipantParams> {
final MeetingRepository repository;

GetParticipant(this.repository);

@override
Future<Either<Failure, Participant>> call(
GetPariticipantParams params,
) async {
return await repository.getParticipantById(params.participantId);
}
}

class GetPariticipantParams extends Equatable {
final int participantId;

const GetPariticipantParams({required this.participantId});

@override
List<Object> get props => [participantId];
}
Loading

0 comments on commit 1535b64

Please sign in to comment.