disconnect method
Disconnects the socket with status code
and reason
for the disconnect
Implementation
void disconnect({Function? callback, int? code, String? reason}) {
final conn = this.conn;
if (conn != null) {
connState = SocketStates.disconnected;
if (code != null) {
conn.sink.close(code, reason ?? '');
} else {
conn.sink.close();
}
this.conn = null;
}
if (callback != null) callback();
}