Marco
8f4cd2266f
This is another step to allow reconnecting after connection loss or browser closing. When the game is left with the X button on the bottom right, we will close the websocket connection, to let the server know, that we are gone. The server still has issues that prevent this from working flawlessly. Remove unused import
44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
import 'package:uuid/uuid.dart';
|
|
|
|
class PlayerInfo {
|
|
final UuidValue? playerID;
|
|
final UuidValue? lobbyID;
|
|
final String? passphrase;
|
|
|
|
const PlayerInfo({
|
|
required this.playerID,
|
|
required this.lobbyID,
|
|
required this.passphrase,
|
|
});
|
|
|
|
factory PlayerInfo.fromJson(Map<String, dynamic> json) {
|
|
final playerid = UuidValue.fromString(json['playerID']);
|
|
final lobbyid = UuidValue.fromString(json['lobbyID']);
|
|
final passphrase = json['passphrase'];
|
|
|
|
return PlayerInfo(
|
|
playerID: playerid, lobbyID: lobbyid, passphrase: passphrase);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'playerID': playerID,
|
|
'lobbyID': lobbyID,
|
|
'passphrase': passphrase,
|
|
};
|
|
}
|
|
|
|
class WebsocketMessageIdentifyPlayer {
|
|
final String playerID;
|
|
final String lobbyID;
|
|
final String? passphrase;
|
|
|
|
const WebsocketMessageIdentifyPlayer({
|
|
required this.playerID,
|
|
required this.lobbyID,
|
|
required this.passphrase,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() =>
|
|
{'lobbyID': lobbyID, 'playerID': playerID, 'passphrase': passphrase};
|
|
}
|