Reputation: 761
I'm trying to create command line Dart apps that have two goals:
They can be easily launched in debugging mode from IntelliJ (IJ) or the Dart Editor (DE) without involving the Dartium browser as I develop Java-based web services that will run in an embedded Jetty server. This will support a TDD workflow.
By incorporating Dart unit tests, each app could become a web service tester that can be run under Jenkins.
It appears that importing dart:html in a source file triggers expectations in both IJ and DE that an HTML page is the entry point into the Dart main(). Also (in IJ), the Select/Run/Debug items in the context menu are not added for Dart source files that import dart:html but are for my unittest source files without this import statement. This complicates the workflow by requiring that my Dartium browser become involved. I have successfully created a simple echo WS script using the recipe shown in the section A Command Line WebSocket Client, but this example only listens for but does not send messages. In fact, the API of the io:WebSocket has no 'send' method as does its html:WebSocket counterpart. The io:WebSocket appears to be much weaker than its 'html' counterpart. So for my use cases (or for someone trying to write a middle-tier Dart-based server), can this be done and how?
Upvotes: 2
Views: 477
Reputation: 941
I do pretty extensive work with server-side WebSocket programming in Dart, and it seems quite full-featured to me. Lately, I've been using the Redstone framework with the WebSocket plugin, which removes much of the boilerplate and makes it almost too easy...
Upvotes: 3
Reputation: 657308
You can. As far as I remember in dart:io
it is just add
instead of send
. I didn't have the impression that the io:WebSocket
has less capabilities.
See https://api.dartlang.org/apidocs/channels/be/dartdoc-viewer/dart:io.WebSocket#id_add
You have to click the add
link below Methods
(deep links don't work properly yet in api.dartlang.org).
Upvotes: 2