Created with <3 with dartpad.dev.
Created
August 2, 2022 19:58
-
-
Save kika/fe4b25c39df11dd4186682ac940c8bdf to your computer and use it in GitHub Desktop.
resonating-destiny-0416
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:html'; | |
void main() async { | |
try { | |
final socket = await wsConnect('wss://127.0.0.1:7654'); | |
print('${socket.readyState}'); | |
} catch (e) {print(e);} | |
} | |
Future<WebSocket> wsConnect(String url) async { | |
final socket = WebSocket(url); | |
socket.onError.listen((_) => throw Exception('connection error')); | |
socket.onClose.listen((_) => throw Exception('connection close')); | |
return socket; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment