Discussion:
[dart-misc] WebRTC for client-server communication
Andreas Paulus
2015-08-11 12:55:48 UTC
Permalink
Hi,

I want to make a realtime multiplayer game using WebRTC. I do not want to
go peer2peer but client-server and wanted to use dart for this.
Unfortunatelly the server console application cannot use dart:html and thus
cannot access the RtcPeerConnection class. I know it is implemented in the
browser so it is not possible to port it over to dart:io and it will never
happen (https://github.com/dart-lang/sdk/issues/18426).

I could try to work around this using a web-based dart app running in
dartium which forwards all data received from WebRTC clients to my dart
console application via websocket but I don't like this approach because
- I don't think there is a headless mode so I cannot deploy this easily
- I don't think is scales well because of the single threaded context in
which the RtcPeerConnection lives inside dartium.

There must be a better way.

I am really hesitant to use native libraries
(http://www.webrtc.org/native-code/development) because it sounds like a
lot of work to integrate it into my dart command line app.


Any advice?
--
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

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Günter Zöchbauer
2015-08-11 15:13:49 UTC
Permalink
You might take a look at https://pub.dartlang.org/packages/webrtc_utils
I don't know WebRTC but I know the author of the package dived in quite
deep.
You can try to contact him if the code of the package doesn't answer your
questions.
Post by Andreas Paulus
Hi,
I want to make a realtime multiplayer game using WebRTC. I do not want to
go peer2peer but client-server and wanted to use dart for this.
Unfortunatelly the server console application cannot use dart:html and
thus cannot access the RtcPeerConnection class. I know it is implemented in
the browser so it is not possible to port it over to dart:io and it will
never happen (https://github.com/dart-lang/sdk/issues/18426).
I could try to work around this using a web-based dart app running in
dartium which forwards all data received from WebRTC clients to my dart
console application via websocket but I don't like this approach because
- I don't think there is a headless mode so I cannot deploy this easily
- I don't think is scales well because of the single threaded context in
which the RtcPeerConnection lives inside dartium.
There must be a better way.
I am really hesitant to use native libraries (
http://www.webrtc.org/native-code/development) because it sounds like a
lot of work to integrate it into my dart command line app.
Any advice?
--
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

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Andreas Paulus
2015-08-11 15:21:46 UTC
Permalink
Thanks for the input :)
Unfortunately this library is based on dart:html which cannot be used on
dart console apps. See the comment from Robert Hartung over here:
https://groups.google.com/a/dartlang.org/forum/#!msg/misc/7imhJDbuCmc/uqNDU-jBwOoJ
Post by Günter Zöchbauer
You might take a look at https://pub.dartlang.org/packages/webrtc_utils
I don't know WebRTC but I know the author of the package dived in quite
deep.
You can try to contact him if the code of the package doesn't answer your
questions.
Post by Andreas Paulus
Hi,
I want to make a realtime multiplayer game using WebRTC. I do not want to
go peer2peer but client-server and wanted to use dart for this.
Unfortunatelly the server console application cannot use dart:html and
thus cannot access the RtcPeerConnection class. I know it is implemented in
the browser so it is not possible to port it over to dart:io and it will
never happen (https://github.com/dart-lang/sdk/issues/18426).
I could try to work around this using a web-based dart app running in
dartium which forwards all data received from WebRTC clients to my dart
console application via websocket but I don't like this approach because
- I don't think there is a headless mode so I cannot deploy this easily
- I don't think is scales well because of the single threaded context in
which the RtcPeerConnection lives inside dartium.
There must be a better way.
I am really hesitant to use native libraries (
http://www.webrtc.org/native-code/development) because it sounds like a
lot of work to integrate it into my dart command line app.
Any advice?
--
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

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Natalie Weizenbaum' via Dart Misc
2015-08-11 18:12:18 UTC
Permalink
Why not just implement WebRTC yourself on top of dart:io's socket
infrastructure? The original bug was closed with that recommendation.
Post by Andreas Paulus
Thanks for the input :)
Unfortunately this library is based on dart:html which cannot be used on
https://groups.google.com/a/dartlang.org/forum/#!msg/misc/7imhJDbuCmc/uqNDU-jBwOoJ
Post by Günter Zöchbauer
You might take a look at https://pub.dartlang.org/packages/webrtc_utils
I don't know WebRTC but I know the author of the package dived in quite
deep.
You can try to contact him if the code of the package doesn't answer your
questions.
Post by Andreas Paulus
Hi,
I want to make a realtime multiplayer game using WebRTC. I do not want
to go peer2peer but client-server and wanted to use dart for this.
Unfortunatelly the server console application cannot use dart:html and
thus cannot access the RtcPeerConnection class. I know it is implemented in
the browser so it is not possible to port it over to dart:io and it will
never happen (https://github.com/dart-lang/sdk/issues/18426).
I could try to work around this using a web-based dart app running in
dartium which forwards all data received from WebRTC clients to my dart
console application via websocket but I don't like this approach because
- I don't think there is a headless mode so I cannot deploy this easily
- I don't think is scales well because of the single threaded context in
which the RtcPeerConnection lives inside dartium.
There must be a better way.
I am really hesitant to use native libraries (
http://www.webrtc.org/native-code/development) because it sounds like a
lot of work to integrate it into my dart command line app.
Any advice?
--
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
To unsubscribe from this group and stop receiving emails from it, send an
--
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

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Andreas Paulus
2015-08-12 15:21:38 UTC
Permalink
I guess I have to try something like this. However the C++ implementation
is quite intimidating:
https://chromium.googlesource.com/external/webrtc/+/master/talk/app/webrtc
Maybe I can just implement a minimum piece of the spec
(http://w3c.github.io/webrtc-pc/) which is needed for establishing a
DataChannel because the whole thing looks like a lot of work, too.

I'll give it a try on the weekend... any tips on where I should start or
reference implementations are welcome ;)

Btw I don't think the content_shell based approach would work
(content_shell seems to be unstable, it crashes on startup, at least on my
windows 8.1x64 machine) and I also don't think I can somehow use the native
implementations. Implementing it on top of dart:io seems to be the only way.
Post by 'Natalie Weizenbaum' via Dart Misc
Why not just implement WebRTC yourself on top of dart:io's socket
infrastructure? The original bug was closed with that recommendation.
Post by Andreas Paulus
Thanks for the input :)
Unfortunately this library is based on dart:html which cannot be used on
https://groups.google.com/a/dartlang.org/forum/#!msg/misc/7imhJDbuCmc/uqNDU-jBwOoJ
Post by Günter Zöchbauer
You might take a look at https://pub.dartlang.org/packages/webrtc_utils
I don't know WebRTC but I know the author of the package dived in quite
deep.
You can try to contact him if the code of the package doesn't answer
your questions.
Post by Andreas Paulus
Hi,
I want to make a realtime multiplayer game using WebRTC. I do not want
to go peer2peer but client-server and wanted to use dart for this.
Unfortunatelly the server console application cannot use dart:html and
thus cannot access the RtcPeerConnection class. I know it is implemented in
the browser so it is not possible to port it over to dart:io and it will
never happen (https://github.com/dart-lang/sdk/issues/18426).
I could try to work around this using a web-based dart app running in
dartium which forwards all data received from WebRTC clients to my dart
console application via websocket but I don't like this approach because
- I don't think there is a headless mode so I cannot deploy this easily
- I don't think is scales well because of the single threaded context
in which the RtcPeerConnection lives inside dartium.
There must be a better way.
I am really hesitant to use native libraries (
http://www.webrtc.org/native-code/development) because it sounds like
a lot of work to integrate it into my dart command line app.
Any advice?
--
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
To unsubscribe from this group and stop receiving emails from it, send an
--
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

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Andreas Paulus
2015-08-11 15:17:49 UTC
Permalink
After some more research I found that content_shell could allow me to
create a RtcPeerConnection which gets connected to every client via a
signalling server. I guess I could even use the signalling server as a kind
of load balancer and have multiple RtcPeerConnections on different ports of
the same machine or even machines in the same LAN to increase the
throughput and utilize additional CPU cores?
The data received from the RtcPeerConnections inside those content_shell
instances would then be forwarded to my main game server (a console dart
app) via websocket and vice versa.

I am quite curious if I am missing something here because I could avoid
having to use the native WebRTC implementations this way and stay
completely in dart code ;)
Any input is appreciated!
--
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

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Andreas Reiter
2015-08-17 12:45:08 UTC
Permalink
I had the exact same problem, and looked into implementing WebRTC on top
of dart:io, but this seems to be A LOT of work with all the associated
ICE, STUN, TURN and so on protocols.

My (nasty) workaround uses a nodejs instance running on the same machine
which exposes the WebRTC API (based on node-wrtc) over TCP.
Dart connects to the exposed TCP port and provides a wrapper.
You can seamlessly switch between browser and nodejs implementation, and
use it the same way as the browser implementation.

Find it at: https://github.com/areiter/nodejs-dart-webrtc-wrapper

Best regards,
Andreas
Post by Andreas Paulus
Hi,
I want to make a realtime multiplayer game using WebRTC. I do not want
to go peer2peer but client-server and wanted to use dart for this.
Unfortunatelly the server console application cannot use dart:html and
thus cannot access the RtcPeerConnection class. I know it is implemented
in the browser so it is not possible to port it over to dart:io and it
will never happen (https://github.com/dart-lang/sdk/issues/18426).
I could try to work around this using a web-based dart app running in
dartium which forwards all data received from WebRTC clients to my dart
console application via websocket but I don't like this approach because
- I don't think there is a headless mode so I cannot deploy this easily
- I don't think is scales well because of the single threaded context in
which the RtcPeerConnection lives inside dartium.
There must be a better way.
I am really hesitant to use native libraries
(http://www.webrtc.org/native-code/development) because it sounds like a
lot of work to integrate it into my dart command line app.
Any advice?
--
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
To unsubscribe from this group and stop receiving emails from it, send
--
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

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Andreas Paulus
2015-08-18 16:36:50 UTC
Permalink
Thank you very much, Andreas :)

You are right, implementing all of those protocols is a lot of work. The
only thing I may have tried was to implement a native wrapper
around http://opentools.homeip.net/webrtc but I'm glad you came up with
this node wrapper.
I think it's not so bad:
- latency increase should be less than 2ms when running on the same machine
- nodejs is single threaded but very efficient with async io so I guess
this node wrapper should at least be able to deal with a few hundred
clients with every client sending and receiving around 10 small messages
per second via data channel. I got to do some load test to prove that ;)

Again, thanks for sharing your wrapper!

Cheers,
Andreas
Post by Andreas Reiter
I had the exact same problem, and looked into implementing WebRTC on top
of dart:io, but this seems to be A LOT of work with all the associated
ICE, STUN, TURN and so on protocols.
My (nasty) workaround uses a nodejs instance running on the same machine
which exposes the WebRTC API (based on node-wrtc) over TCP.
Dart connects to the exposed TCP port and provides a wrapper.
You can seamlessly switch between browser and nodejs implementation, and
use it the same way as the browser implementation.
Find it at: https://github.com/areiter/nodejs-dart-webrtc-wrapper
Best regards,
Andreas
Post by Andreas Paulus
Hi,
I want to make a realtime multiplayer game using WebRTC. I do not want
to go peer2peer but client-server and wanted to use dart for this.
Unfortunatelly the server console application cannot use dart:html and
thus cannot access the RtcPeerConnection class. I know it is implemented
in the browser so it is not possible to port it over to dart:io and it
will never happen (https://github.com/dart-lang/sdk/issues/18426).
I could try to work around this using a web-based dart app running in
dartium which forwards all data received from WebRTC clients to my dart
console application via websocket but I don't like this approach because
- I don't think there is a headless mode so I cannot deploy this easily
- I don't think is scales well because of the single threaded context in
which the RtcPeerConnection lives inside dartium.
There must be a better way.
I am really hesitant to use native libraries
(http://www.webrtc.org/native-code/development) because it sounds like
a
Post by Andreas Paulus
lot of work to integrate it into my dart command line app.
Any advice?
--
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
Post by Andreas Paulus
To unsubscribe from this group and stop receiving emails from it, send
--
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

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...