Dart Client / Server Communication

474 views
Skip to first unread message

Runar Jordahl

unread,
Aug 11, 2013, 2:43:11 PM8/11/13
to mi...@dartlang.org

I am looking into making a Dart application that will have the domain classes defined on both the server and the client. I will use Dart serialization ( http://api.dartlang.org/docs/releases/latest/serialization.html ) to send/receive the objects. My question is about how I should do the communication between client and server:

Is “web sockets” the preferred communication method? I briefly looked the example below, but I think it will no longer work in the latest version:
https://www.dartlang.org/docs/dart-up-and-running/contents/ch05.html

Should I dig into the code and try to update it, or is it a dead end? Maybe it is only Dart UI changes, which makes this example no longer valid?

Are there other frameworks / techniques that are preferred over “web sockets”?

Kind regards,
Runar

jim.trainor.kanata

unread,
Aug 11, 2013, 2:47:27 PM8/11/13
to mi...@dartlang.org
Is it a browser client?

I guess you want a persistent connection since you're talking about WebSockets?


Runar Jordahl wrote:
--
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

Frank Pepermans

unread,
Aug 11, 2013, 3:00:22 PM8/11/13
to mi...@dartlang.org

You could check out google's proto buffers, the dart lib was released earlier this week.

Runar Jordahl

unread,
Aug 11, 2013, 4:19:44 PM8/11/13
to mi...@dartlang.org

Jim: Yes, the client is a web application running on the public internet. Therefore, the connection also needs to be secure. I am not sure if I really need the connection to be persistent. I guess I started looking at “web sockets”, since they allow two-way communication, which would be a plus.

After browsing a bit more, I found the article below about REST and Dart. I should probably ready it, although as far as I understand, REST will not allow the server to “push” messages to the client.
https://www.dartlang.org/articles/json-web-service/

Frank: Correct me if I am wrong, but I thought Protocol Buffers would pretty much work like a REST API: It would not allow for pushing messages from server to client.

Runar

Fabio Kaminski

unread,
Aug 11, 2013, 6:05:02 PM8/11/13
to General Dart Discussion
Runar, 

Speedy and http 2, are what you are looking for, and are the spiritual sucessor of the websockets..
in speedy connections remains open an they allow push type messages from servers to clients.. 

dont know if in the client side the XHR client will get in the way.. but speedy are backed in chrome.. so the only missing part
will be in the server side, cause it means you would need to implement a speedy compatible http...  and i dont think the dart lib current have this right now.. it would something that you would be on your own.. and would have to implement yourself in the server side, and dont think all browsers can support that right now.. so it would be a pretty much chrome only thing?









--

Jim Trainor

unread,
Aug 11, 2013, 9:09:56 PM8/11/13
to mi...@dartlang.org
For all routine server requests you are going to using dart:html.HttpRequest.  If you want server push then I think you are on the right track with WebSockets. I haven't used them personally (although I have done server push with some now out-dated methods).  You'll find that Dart is pretty thin layer on top of the web browser and sorting out most such problems is more about understanding the browser interfaces than understanding Dart per se.

Your serialization method an be anything you like.  I have my own home-brewed solution for Dart native class serialization.  The REST article is good example. If you stick with Json then serialize is it not a big deal whatever path you end up going down.  There is no really well develop, seamless, native serialization in Dart yet AFAIK. At nothing as seamless as you'll find, for example, in Java.

Randal L. Schwartz

unread,
Sep 7, 2013, 9:18:11 PM9/7/13
to mi...@dartlang.org
>>>>> "Frank" == Frank Pepermans <fr...@igindo.com> writes:

Frank> You could check out google's proto buffers, the dart lib was released
Frank> earlier this week.

How about msgpack? If we had a good implementation of that, it'd be far
superior to JSON or Proto Buffers, and it would also be language
independent.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig

Alex Tatumizer

unread,
Sep 7, 2013, 10:23:21 PM9/7/13
to mi...@dartlang.org, mer...@stonehenge.com
> How about msgpack? ...

Serialization will either be efficient or generic (= "working for any object"). If you want it to be both... good luck with that.
The only choice I see is to impose restrictions on object structure so that efficient serialization is possible, and design both restrictions and serialization in tandem.
Which is what I tried to do in pigeon_map.
Serialization is fast, and restrictions are not really very restrictive. 
Take a look: https://github.com/tatumizer/pigeon_map (or just pigeon_map in pub).
For binary format, I used something homegrown because I didn't like UTF-8 in Msgpack (for performance reasons; UTF-8 is foreign in dart/javascript world).
(Certainly, there can be other variants of the idea, but I challenge anyone to beat Pigeon first. :-)
 
Reply all
Reply to author
Forward
0 new messages