JSPM

  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q24788F
  • License MIT

webRTC PvP connection on Datachannel with losand

Package Exports

  • losand.pvp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (losand.pvp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

losand.pvp

It's a usecase about ...

npm i losand.pvp

import server.js file

require("losand.pvp")(__dirname + '/public', 'index.html', port, ip);
//port and ip is opthional

Creat a public folder and make in a index.html

You use it tags

  <script src="https://cdn.jsdelivr.net/npm/losand@1.5.0/losand.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/dsand@0.6.5/dsand.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/dsand@0.6.5/pvp.js"></script>
  <script>
    _($.role).draw({
      pvpCE (channel) {
        /* Anything do when connection Established
           Channel is WebRTC Data Channel 
        */
        $(channel).class("hear").on("message");
      },
      hear (e) {
        alert(e.data);
      }
    })
    PvP()()();
  </script>
node server.js

and access the two clients;

Usage on BrowserSide PvP function

PvP(
  // 1st Negotiation info
  {
  blockedUserList: [],
  gameRating: 1000,
  friendOnry: true
})(
  // 2nd Custom Origin
  "https://test.io/"
)(
  // 3rd STUN Address or TURNServer Authentication info Object
  "stun:l.google...",
  {
    url: "turn:...",
    credential: "...",
    username: ""
  }
)

// $.pvp get's WebRTC DataChannel Object
$.pvp.send("hello");