0

I have a project that requires websockets. I was going to use Node.js , but now I am wondering if Dart M3, respective to websockets, would suit my use case.

There are open questions like:

  • How do i deploy/host my server-side dartcode (websocket server)?
  • Can I create multiple "rooms", where I would be able to send messages, and where subscribed clients (browsers) receive automatically those messages?
  • How many clients can subscribe to those "rooms"?
  • ...

Should I just roll for now with Node.js and wait a bit till dart gets ready?

Thx

Gero
  • 12,993
  • 25
  • 65
  • 106

1 Answers1

3

Specific answers to your open questions are:

How do i deploy/host my server-side dartcode (websocket server)?

You write your server-side dart code, with an entry point dart file (eg, my_app.dart, and execute it with the Dart binary on a server somewhere. This is the same as node.js.

Can I create multiple "rooms", where I would be able to send messages, and where subscribed clients (browsers) receive automatically those messages?

This is a programming challenge for you. When a client makes a websocket connection, the server gets an instance of a connection object. One possibility solution is that you maintain a list of rooms, and add each client's connection to each room that the client wants to connect to. Alternatively, maintain a list of client objects, and have a list of rooms for this client. (this is the same problem you would have to solve if you used node.js).

How many clients can subscribe to those "rooms"?

How long is a piece of string? Programatically, no limit, however you would be limited by ram, hardware .... (try it, and let us know how your app performs under load) - see this related question: Socket.io: How many concurrent connections can WebSockets handle? and the associated accepted answer (again, this is not actually Dart specific).

Essentially, using Dart on the server side technology-wise is a very similar choice to using node.js on the server side. What you get with Dart is the strong type checking, tooling, library imports baked into the language, and classic OOP that you don't get with a JavaScript solution.

Seth Ladd's blog post about Dart WebSockets explains more (the specific syntax is probably slightly out of date, but the concepts are still the same).

Community
  • 1
  • 1
Chris Buckett
  • 13,738
  • 5
  • 39
  • 46