Istvan Soos
2017-03-20 09:29:57 UTC
Hi Dartisans,
I've drafted a high-level messaging API that could work in various
environments that need some kind of boundary cross (wire format and
object serialization, e.g. between web- and service workers, web
sockets...). My desire is that instead of sending a blob through
postMessage() and rolling your own parsing on the other side, most
applications could define their own data types and communication model
in a more apparent way.
The main idea is that each side of the pipe provides a 'hub':
https://github.com/isoos/message_hub/blob/master/lib/message_hub.dart#L5
You register adapters that handle the serialization and deserialization:
https://github.com/isoos/message_hub/blob/master/lib/message_hub.dart#L7
You register message handlers (a service that responds to requests):
https://github.com/isoos/message_hub/blob/master/lib/message_hub.dart#L16
And the rest of the API is either generic stream (sendMessage,
onMessage) or request-reply model (call, invoke).
I've also drafted three "transport handler" for web_worker, web_socket
and service_worker, which gives you an idea how this may work on
different transports:
https://github.com/isoos/message_hub/tree/master/lib
Please, please, please, let me know what you think about it! I'd like
to have a polished API that may be useful for different projects. It
is not used anywhere yet, and it is possible to change it in any way
that provides an improvement.
Thanks,
Istvan
I've drafted a high-level messaging API that could work in various
environments that need some kind of boundary cross (wire format and
object serialization, e.g. between web- and service workers, web
sockets...). My desire is that instead of sending a blob through
postMessage() and rolling your own parsing on the other side, most
applications could define their own data types and communication model
in a more apparent way.
The main idea is that each side of the pipe provides a 'hub':
https://github.com/isoos/message_hub/blob/master/lib/message_hub.dart#L5
You register adapters that handle the serialization and deserialization:
https://github.com/isoos/message_hub/blob/master/lib/message_hub.dart#L7
You register message handlers (a service that responds to requests):
https://github.com/isoos/message_hub/blob/master/lib/message_hub.dart#L16
And the rest of the API is either generic stream (sendMessage,
onMessage) or request-reply model (call, invoke).
I've also drafted three "transport handler" for web_worker, web_socket
and service_worker, which gives you an idea how this may work on
different transports:
https://github.com/isoos/message_hub/tree/master/lib
Please, please, please, let me know what you think about it! I'd like
to have a polished API that may be useful for different projects. It
is not used anywhere yet, and it is possible to change it in any way
that provides an improvement.
Thanks,
Istvan
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.