Coder Social home page Coder Social logo

tommyteavee / librtcdc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xhs/librtcdc

0.0 0.0 0.0 125 KB

librtcdc is a tiny WebRTC Data Channel implementation that works everywhere.

Home Page: https://github.com/xhs/librtcdc

License: Other

Shell 0.14% Python 19.85% Makefile 1.10% C 78.91%

librtcdc's Introduction

librtcdc is a tiny WebRTC DataChannel implementation that works everywhere (Beta).

BEING REWRITEN

Features

  • Tiny <2k LOC, easy to understand/bind/extend
  • Talks with each other, latest Chrome/Chromium, Firefox, Opera?, Safari?
  • 'Official' Python binding
  • Lack of docs

Prerequisites

Python demo

import pyrtcdc
from pyrtcdc import PeerConnection

# called when the channel received a message
def on_message(channel, datatype, data):
    print 'received data from channel %s: %s' %(channel.label, data)
    channel.send(pyrtcdc.DATATYPE_STRING, 'Roger')

# called when a channel is created by the remote peer
def on_channel(peer, channel):
    print 'channel %s created' %(channel.label)
    channel.on_message = on_message

# called when a new local candidate is found
def on_candidate(peer, candidate):
    print 'local candidate sdp:\n%s' %(candidate)

# called when connected to remote peer
def on_connect(peer):
  peer.create_data_channel('demo', on_open=on_open)

# called when channel is opened
def on_open(channel):
  channel.on_message = on_message
  channel.send(pyrtcdc.DATATYPE_STRING, 'Hi')

peer = PeerConnection(on_channel, on_candidate, stun_server='stun.services.mozilla.com')

# generate local offer sdp and start candidates gathering
offer = peer.generate_offer()

# offer/answer/candidates signalling here (or somewhere)
# ...

# running until the sun cools
peer.loop()

License

BSD 2-Clause

librtcdc's People

Contributors

saghul avatar xhs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.