An open API service indexing awesome lists of open source software.

https://github.com/vaakian/xpeer

XPeer is a WebRTC based package for building Muti-Peer-to-Peer Frontend Application.
https://github.com/vaakian/xpeer

datachannel muti-peerconnection p2p video-conferencing webrtc

Last synced: about 2 months ago
JSON representation

XPeer is a WebRTC based package for building Muti-Peer-to-Peer Frontend Application.

Awesome Lists containing this project

README

          

## Clarification

this project is for the purpose of learning NPM/webRTC/package building/WebRTC for myself, so it's definitely unusable and you may play with it for the same purpose, **but `DO NOT` ever try it in a real project(s) at all.**

if you're looking for WebRTC related tools, here are several projects I would recommend:

- [simple-peer](https://github.com/feross/simple-peer): muti-p2p WebRTC connection(more than just 1 to 1), it also provides a [@types/simple-peer](https://www.npmjs.com/package/@types/simple-peer) package to enable intellisense or type chekcing.
- [peer.js](https://github.com/peers/peerjs): fully written in TypeScript.
- [WebRTC-Experiment](https://github.com/muaz-khan/WebRTC-Experiment): whole lot of examples to learn.

----

## [XPeer](#) · [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/vaakian/xpeer/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/xpeer.svg?style=flat)](https://www.npmjs.com/package/xpeer) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#)

## install & usage

### npm
```shell
npm i -s xpeer
```
### yarn
```shell
yarn add xpeer
```
## signal server

> NOTE: to use XPeer, the [XSignal](https://github.com/vaakian/XSignal) is essential to work with, provides signal exchanging services between peers.

## TODO
- [ ] 封装文件发送`sendFile(file)`和接收`emit('file', file)`,自动编解码,并提供发送进度。
- [ ] 重复share视频流,peer自身取消分享事件。
### 项目引入

[MDN: RTCPeerConnection](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection)
```js
import XPeer, { XPeerInit } from 'xpeer'
const options: XPeerInit = {
signalServer: string, // 'ws://localhost:8080',
peerConfig: RTCConfiguration
}
const xPeer = new XPeer(options)
```

### 外部``引入

```html
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入 -->
<script src="https://raw.githubusercontent.com/vaakian/XPeer/main/bundle/xpeer.bundle.min.js">
XPeer

// 直接使用
const xPeer = new XPeer({
signalServer: string, // 'ws://localhost:8080',
peerConfig: RTCConfiguration
})