close method
Implementation
void close(String? id, [int? closeCode, String? closeReason]) {
IOWebSocketChannel? client = _clientMap[id!];
// has not connect
if (client == null) {
if (!_stateMap.containsKey(id)) {
_WebSocketState state = _WebSocketState(_ConnectionState.closed);
state.data = [closeCode, closeReason];
_stateMap[id] = state;
} else {
_WebSocketState state = _stateMap[id]!;
state.status = _ConnectionState.closed;
state.data = [closeCode, closeReason];
}
return;
}
// connected
client.sink.close(closeCode, closeReason);
}