mirror of
https://github.com/esiur/esiur-dart.git
synced 2025-06-26 22:33:12 +00:00
WS
This commit is contained in:
@ -103,12 +103,32 @@ class WSocket extends ISocket {
|
||||
Uri.parse("${secure ? 'wss' : 'ws'}://${hostname}:${port}"),
|
||||
); //binaryType: BinaryType.list);
|
||||
|
||||
_state = SocketState.Established;
|
||||
if (_channel == null)
|
||||
{
|
||||
rt.triggerError(AsyncException(ErrorType.Management,
|
||||
ExceptionCode.HostNotReachable.index, "Can't create WebSocketChannel."));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_channel!.closeCode != null)
|
||||
rt.triggerError(AsyncException(ErrorType.Management,
|
||||
ExceptionCode.HostNotReachable.index, "WebSocketChannel " + _channel!.closeCode.toString()));
|
||||
|
||||
begin();
|
||||
receiver?.networkConnect(this);
|
||||
rt.trigger(true);
|
||||
} catch (ex) {
|
||||
_channel!.ready.then((x){
|
||||
_state = SocketState.Established;
|
||||
|
||||
begin();
|
||||
receiver?.networkConnect(this);
|
||||
rt.trigger(true);
|
||||
|
||||
}).onError((ex, s){
|
||||
rt.triggerError(AsyncException(ErrorType.Management,
|
||||
ExceptionCode.HostNotReachable.index, ex.toString()));
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
} catch (ex) {
|
||||
rt.triggerError(AsyncException(ErrorType.Management,
|
||||
ExceptionCode.HostNotReachable.index, ex.toString()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user