WIP ws messages, TODO backend receiving frontend messages

This commit is contained in:
2025-02-19 09:28:13 -07:00
parent b37862a321
commit d2e378b4a3
12 changed files with 104 additions and 153 deletions
+4 -3
View File
@@ -16,17 +16,18 @@ Future<Response> onRequest(RequestContext context) async {
try {
// Parse the request body
final body = await context.request.json();
final createUserReq = CreateUserRequest.fromJson(body as Map<String, dynamic>);
final joinRoomRequest = JoinRoomRequest.fromJson(body as Map<String, dynamic>);
// Generate token
final authenticator = context.read<Authenticator>();
final (token, user) = await authenticator.generateToken(createUserReq);
final (token, user) = await authenticator.generateToken(joinRoomRequest);
if (token == null || user == null) {
final body = CreateUserResponse(
success: false,
token: null,
error: user == null ? 'Room ${createUserReq.roomCode} requested is not available' : 'Unexpected error occurred',
error:
user == null ? 'Room ${joinRoomRequest.roomCode} requested is not available' : 'Unexpected error occurred',
uuid: null,
).toJson();
return Response.json(