connect method
Implementation
Future<ProConnectionStatus> connect() async {
// destroy the socket and the listeners if they exist
disconnect();
if (ip.isEmpty || port == 0) return ProConnectionStatus.failed;
status = ProConnectionStatus.connecting;
ws = WS('sdSocket');
socketListener = ws.messages.listen((msg) => messageHandler(msg.data));
socketStatusListener = ws.connectionStatus.listen((bool b) {
status = b ? ProConnectionStatus.connected : ProConnectionStatus.failed;
});
// connect and then immediately send a first message
ws.connect(
'ws://$ip:$port/stagedisplay',
usePing: false,
firstMessage: WSMessage(data: {
'pwd': password,
'ptl': version == ProVersion.seven ? PRO7_SD_PROTOCOL : PRO6_SD_PROTOCOL,
'acn': "ath",
}),
);
return delayedConnectionCheck();
}