Giter Site home page Giter Site logo

cmadh / webrtcnetwork Goto Github PK

View Code? Open in Web Editor NEW

This project forked from devluz/webrtcnetwork

0.0 0.0 0.0 150 KB

A simple and well defined API to access WebRTC DataChannels from Unity or Emscripten

License: MIT License

JavaScript 51.71% HTML 7.41% CSS 0.69% C# 40.19%

webrtcnetwork's Introduction

Note: This is the old java script version of WebRtcNetwork. It is now under the MIT license so you can use it any way you want!

The Unity Asset WebRtcNetwork switched to a complete new rewritten type script library. (will be published on github in the future)

WebRTCNetwork

A simple and well defined API to access WebRTC DataChannels from Unity or Emscripten

for Unity

The unity version is contained in an example project (folder unitywebrtc). Simply open the project in Unity and build the WebGL version. It should run without any additional changes.

WebRtcNetwork

This is the main class of the system. It allows you to start a allow incomming connections or connect to another system. The connections are unlike websockets direct connections. It allows tcp style ordered, reliable data transfer or udp style unordered, unreliable messages.

The way a connection is etablished is rather different from other libraries due to the structure of WebRTC. While TCP and UDP use the IP address+port to connect directly, WebRTC needs a custom signaling server that delegates the etablishment between two systems. Handling of ip addresses, ports and NAT traversal is all done automatically.

The example uses a test signaling server so it should work immediately. You can setup your own signaling server using a socket.io server (code in socketiosignalingserver) or a firebase account (free for 30CCU)

Note: As WebRTC is a browser functionality the WebRtc class won't work in the Unity Editor or any other build. See UnityNetwork

UnityNetwork

Unity Network is a helper class that allows you to similate the behaviour of WebRTCNetwork in Unity Editor or builds that support unity network. It won't work while set up for "WebGL" though! Make sure it isn't set in the build settings! The chat example shows how you can use this class to test your network code locally. I would not recomment using this class in any release builds as it might not be unstable. Also note that unity network doesn't support multiple servers/connections at the same time thus you can only create one single instance and only start a server or connect to a single server. It also doesn't support connection via a choosen name. After creating a server the ServerInitialzied event will return a randomly choosen number that can be used to connect.

webrtcnetwork's People

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.