readFromServer method

Future<void> readFromServer(
  1. UDP sendSocket,
  2. Endpoint client
)

Implementation

Future<void> readFromServer(UDP sendSocket, Endpoint client) async {
  sendSocket.asStream().timeout(Duration(seconds: 5), onTimeout: (d) {
    _online = false;
  }).listen((packet) async {
    if (!_online) _online = true;
    if (packet != null) {
      if (packet.data[0] == Constants.unconnectedPongId) {
        await _listenSocket.send(_rewritePong(packet.data), client);
      } else {
        await _listenSocket.send(packet.data, client);
      }
    }
  });
}