resume function
Implementation
Future<void> resume(String roomID, BuildContext context) async {
GameSocket s = GameSocket();
Completer completer = Completer<void>();
// BoardData b = BoardData();
s.socket.on(
'error',
(data) => {
// print(data)
});
s.socket.once(
'room_created',
(data) => {
s.room = data[0]["roomID"],
},
);
s.socket.once(
'room',
(data) => {
s.room = data[0]["roomID"],
s.iAmWhite = data[0]["color"] == "LIGHT",
s.pendingMovements = data[0]["moves"],
s.timer = data[0]["initialTimer"],
s.type = data[0]["gameType"],
s.player1 = data[0]["light"],
s.player2 = data[0]["dark"],
// print(s.room),
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const GamePage()),
),
completer.complete()
});
var jsonData = {"gameID": roomID};
s.socket.emit("resume", jsonData);
return completer.future;
}