Skip to content

Commit

Permalink
Changed the JoinSession (removed the pin) and added share_plus versio…
Browse files Browse the repository at this point in the history
…n 7.0.2
  • Loading branch information
F4zination committed Apr 24, 2024
1 parent 76ffa22 commit 36a9f52
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion duo_client/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
Expand Down
4 changes: 2 additions & 2 deletions duo_client/lib/provider/api_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class ApiProvider extends ChangeNotifier implements AbstractServerConnection {
}

@override
Future<int> joinSession(String token, int sessionId, String pin) {
return _serverConnection!.joinSession(token, sessionId, pin);
Future<int> joinSession(String token, int sessionId) {
return _serverConnection!.joinSession(token, sessionId);
}

@override
Expand Down
2 changes: 1 addition & 1 deletion duo_client/lib/utils/connection/abstract_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ abstract class AbstractServerConnection {
Future<int> registerUser(String username);
Future<int> loginUser(String uuid);
Future<int> createSession(String token, String pin);
Future<int> joinSession(String token, int sessionId, String pin);
Future<int> joinSession(String token, int sessionId);
Future<int> disconnectSession(String token, int sessionId);
}
5 changes: 2 additions & 3 deletions duo_client/lib/utils/connection/grpc_server_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,12 @@ class GrpcServerConnection extends AbstractServerConnection {
}

@override
Future<int> joinSession(String token, int sessionId, String pin) async {
Future<int> joinSession(String token, int sessionId) async {
try {
ResponseStream<SessionStream> stream =
client.joinSession(JoinSessionRequest()
..token = token
..sessionId = sessionId
..pin = pin);
..sessionId = sessionId);

await for (SessionStream ss in stream) {
print('Received: ${ss.sessionState.users.length}');
Expand Down
17 changes: 12 additions & 5 deletions duo_client/lib/widgets/join_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';

class JoinDialog extends ConsumerStatefulWidget {
const JoinDialog({Key? key});
const JoinDialog({super.key});

@override
ConsumerState<JoinDialog> createState() => _JoinDialogState();
}

class _JoinDialogState extends ConsumerState<JoinDialog> {
TextEditingController _controller = TextEditingController();
final TextEditingController _controller = TextEditingController();
bool wrongInviteCode = false;
String hintText = 'Enter the invite code to join a game';

Expand Down Expand Up @@ -76,12 +76,19 @@ class _JoinDialogState extends ConsumerState<JoinDialog> {
))),
IconButton(
onPressed: () async {
print('Joining session with invite code ${_controller.text}');
if (_controller.text.isEmpty || _controller.text.length < 6) {
setState(() {
wrongInviteCode = true;
hintText = 'Invite code needs to be 6 digits long';
});
return;
}
int stauts = await ref.read(apiProvider).joinSession(
ref.read(storageProvider).accessToken,
5,
_controller.text);
int.parse(_controller.text));
if (stauts == 0) {
print(
'Joining session with invite code ${_controller.text}');
Navigator.of(context)
.pushReplacementNamed(LobbyScreen.route);
} else {
Expand Down
8 changes: 4 additions & 4 deletions duo_client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -700,18 +700,18 @@ packages:
dependency: "direct main"
description:
name: share_plus
sha256: ef3489a969683c4f3d0239010cc8b7a2a46543a8d139e111c06c558875083544
sha256: ed3fcea4f789ed95913328e629c0c53e69e80e08b6c24542f1b3576046c614e8
url: "https://pub.dev"
source: hosted
version: "9.0.0"
version: "7.0.2"
share_plus_platform_interface:
dependency: transitive
description:
name: share_plus_platform_interface
sha256: "0f9e4418835d1b2c3ae78fdb918251959106cefdbc4dd43526e182f80e82f6d4"
sha256: "251eb156a8b5fa9ce033747d73535bf53911071f8d3b6f4f0b578505ce0d4496"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
version: "3.4.0"
shelf:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion duo_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies:
animated_background: ^2.0.0
flutter_spinkit: ^5.2.1
qr_flutter: ^4.1.0
share_plus: ^9.0.0
share_plus: 7.0.2


dev_dependencies:
Expand Down
1 change: 0 additions & 1 deletion proto/session_messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ message CreateSessionResponse{
message JoinSessionRequest{
string token = 1;
int32 session_id = 2;
string pin = 3;
}

message SessionStream{
Expand Down

0 comments on commit 36a9f52

Please sign in to comment.