7

I want to send text messages directly to browser. Till now I'm only seeing the audio/video transmission demos in the web. These are my doubts:

  • Can't we solve this just by using PeerConnection API?
  • Or is the new DataChannel API is required to achieve this?
  • If so, in which browser/browsers the dataChannel APIs are implemented?

Thanks in advance for any help..

Nachiketha
  • 21,705
  • 3
  • 24
  • 32
  • 1
    Chrome canary supports DataChannel ... also firefox nightly: http://mozilla.github.com/webrtc-landing/data_test.html – Muaz Khan Jan 03 '13 at 04:39
  • "send text messages directly to browser" ?? browser to browser .... or simply "to browser" ? .... – Muaz Khan Jan 03 '13 at 04:42
  • @MuazKhan ya, browser to browser. Just like browser to browser video transmission in webrtc. – Nachiketha Jan 03 '13 at 05:22
  • @MuazKhan and also that demo in mozilla.github.com/webrtc-landing/data_test.html doesn't seem to run :( I'm using firefox nightly only.. What has to happen after I click Start button? – Nachiketha Jan 03 '13 at 05:25
  • they used wrong variable...or missed it...you can see it in console... – Muaz Khan Jan 03 '13 at 05:27
  • 1
    This project (https://github.com/muaz-khan/ShareIt) also not worked for me...Personally I'm testing DataChannel APIs and when I get success...I'll upload here: https://github.com/muaz-khan/WebRTC-Experiment – Muaz Khan Jan 03 '13 at 05:29
  • @MuazKhan thanks :) So, we can't develop a chat like application without dataChannel API in webRTC? – Nachiketha Jan 03 '13 at 05:33
  • As I know (I can be wrong) Google Chrome WebRTC team tested DataChannel APIs and they said it worked for them...they may release a simple demo soon... it means that for sure, you can design chatting app. However currently I've not found any working demo...you can post message on discuss-webrtc: groups.google.com/group/discuss-webrtc – Muaz Khan Jan 03 '13 at 05:40
  • You may like this: https://github.com/mozilla/socialapi-demo - http://mozilla.github.com/socialapi-demo/ - I "guess" DataChannel is being used there to send text and images... – Muaz Khan Jan 03 '13 at 05:51

4 Answers4

4

The answer to your question is: Yes - you need to use dataChannel API

Its not cross-browser as they're still implementing it - I'd probably use socket.io with node atm for a cross-browser app.

Once datachannel is done, it'll be AMAZING! :)

harry young
  • 600
  • 1
  • 8
  • 24
3

You need to use the DataChannel part of of the PeerConnection API. This will work in firefox 18 and forward and is coming to Chrome some time soon.

A good starting point to understand how to do this is https://hacks.mozilla.org/2012/11/progress-update-on-webrtc-for-firefox-on-desktop/ and the latest draft of the specification at http://dev.w3.org/2011/webrtc/editor/webrtc.html!

3

There are some JavaScript libraries for sending text data using WebRTC Data Channel API: PeerJS, webRTC.io, DataChannel.io, BoneValue... (add more if you know)

niutech
  • 28,923
  • 15
  • 96
  • 106
0

If you're only concerned about text messages, why not use the WebSocket API instead, which has a much broader support range?

HartleySan
  • 7,404
  • 14
  • 66
  • 119
  • But WebRTC is much faster than websockets no? And also im not interested in just a chat messages.. More concerned abt sending application data in real time. – Nachiketha Jan 26 '13 at 03:21
  • You can safely use WebRTC Data Channel API with WebSockets [fallback](https://github.com/piranna/DataChannel-polyfill). – niutech Feb 17 '13 at 21:12