diff --git a/_includes/demos/dart.dart b/_includes/demos/dart.dart new file mode 100644 index 000000000..f52a8f069 --- /dev/null +++ b/_includes/demos/dart.dart @@ -0,0 +1,26 @@ +import 'dart:async' show Future; +import 'dart:convert' show json; +import 'dart:io' show WebSocket; + +Future main() async { + WebSocket ws; + try { + ws = await WebSocket.connect( + 'wss://ws.binaryws.com/websockets/v3?app_id=1089'); + + if (ws?.readyState == WebSocket.open) { + ws.listen( + (resposne) { + var data = Map.from(json.decode(resposne)); + print('Ticks update:\r\n $data'); + }, + onDone: () => print('Done!'), + onError: (e) => throw new Exception(e), + ); + ws.add(json.encode({'ticks': 'R_100'})); + } + } catch(e) { + ws?.close(); + print('Error: $e'); + } +} diff --git a/_pages/demos.html b/_pages/demos.html index 5bb0bd203..a7045c080 100644 --- a/_pages/demos.html +++ b/_pages/demos.html @@ -11,6 +11,7 @@

{{ page.title }}

+ @@ -31,6 +32,7 @@

{{ page.title }}

{% include demos/clojure.clj %}
{% include demos/coffeescript.coffee %}
{% include demos/csharp.cs %}
+
{% include demos/dart.dart %}
{% include demos/elixir.exs %}
{% include demos/go.go %}
{% include demos/java.java %}