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.
- Host: GitHub
- URL: https://github.com/vaakian/xpeer
- Owner: vaakian
- License: mit
- Created: 2022-01-25T09:17:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-06T15:53:44.000Z (about 3 years ago)
- Last Synced: 2025-07-01T03:04:10.476Z (3 months ago)
- Topics: datachannel, muti-peerconnection, p2p, video-conferencing, webrtc
- Language: TypeScript
- Homepage:
- Size: 188 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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](#) · [](https://github.com/vaakian/xpeer/blob/main/LICENSE) [](https://www.npmjs.com/package/xpeer) [](#)
## 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
})