Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计异常

how-to-build-a-webrtc-signal-server-with-pocketbase如何使用 pocketbase 构建 webrtc 信号服务器

Agent Skill

how-to-build-a-webrtc-signal-server-with-pocketbase 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,257

周安装

54

GitHub Stars

40

下载量

441
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:how-to-build-a-webrtc-signal-server-with-pocketbase(如何使用 pocketbase 构建 webrtc 信号服务器)
来源仓库:https://github.com/rodydavis/skills
仓库路径:skills/how-to-build-a-webrtc-signal-server-with-pocketbase
安装命令:
npx skills add https://github.com/rodydavis/skills --skill how-to-build-a-webrtc-signal-server-with-pocketbase
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/rodydavis/skills --skill how-to-build-a-webrtc-signal-server-with-pocketbase

简介

用于查找、检索和筛选相关信息,支持根据关键词或任务场景定位内容。

  • 适合在需要信息聚合的场景下使用,可结合来源仓库和原始 README 核验具体用法。
  • 安装命令:npx skills add https://github.com/rodydavis/skills --skill how-to-build-a-webrtc-signal-server-with-pocketbase。
  • 适用于 Codex、Claude、Cursor、Gemini CLI,通过 GitHub 安装。
  • 建议确认权限范围和维护状态,注意是否触发联网或文件读写操作。

SKILL.md

How to Build a WebRTC Signal Server with PocketBase

Overview

If you are new to WebRTC then I suggest checking out this great Fireship video on WebRTC in 100 seconds:

Also if you are looking for a Firebase example then check out this repository which this example is largely based on.

This example is built using PocketBase as the signal server for WebRTC and runs SQLite on the server with easy to use realtime SDKs built on top of Server Sent Events (SSE).

Setting up the server

Download PocketBase and create a new directory that we will use for the project.

mkdir webrtc-pocketbase-demo
cd webrtc-pocketbase-demo

Copy the PocketBase binary into the directory you just created under a sub directory .pb. If you are on MacOS you will need to allow the executable to run in settings.

Start the PocketBase server with the following command:

.pb/pocketbase serve

If all goes well you should see the following:

2023/11/04 15:10:56 Server started at http://127.0.0.1:8090
├─ REST API: http://127.0.0.1:8090/api/
└─ Admin UI: http://127.0.0.1:8090/_/

Open up the Admin UI url and create a new username and password.

For this example the email and password will be the following:

Key

Value

Email

[[email protected]](https://github.com/cdn-cgi/l/email-protection#dca8b9afa89cb9a4bdb1acb0b9f2bfb3b1)

Password

Test123456789

You should now see the following:

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2F770w5ti1xz64rxd%2Fweb_rtc_1_sxepcsqwya.png%3Fthumb%3D&s=5a991eb070dabc41)

Creating the collections

ice_servers

Create a new collection named ice_servers with the following columns:

Column Name

Column Type

url

Plain text

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2Fx4211ub82294ju0%2Fweb_rtc_2_18muflf746.png%3Fthumb%3D&s=3fced106b5afa4cc)

Add the following API rule to the List/Search and View:

@request.auth.id != ''

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2Fk18h527ufe4968j%2Fweb_rtc_3_zhpjwks4he.png%3Fthumb%3D&s=c725957e0a2ade57)

After the collection is created add 2 records for each of the following values for the url:

stun:stun1.l.google.com:19302
stun:stun2.l.google.com:19302

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2Fzg457nlf42en421%2Fweb_rtc_4_u30xyj67qq.png%3Fthumb%3D&s=b2bbefe8d673a632)

calls

Create a new collection named calls with the following columns:

Column Name

Column Type

Column Settings

user_id

Relation

Non empty, users, Cascade delete is true

offer

JSON

answer

JSON

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2Fsnt87v3djk6jsny%2Fweb_rtc_5_3x9zuluckq.png%3Fthumb%3D&s=d5084f06c9b4ac78)

it is also possible to limit the user to one call each by setting the Unique constraint on the user_id column.

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2F463dxsby5b402f1%2Fweb_rtc_6_epid0nfuym.png%3Fthumb%3D&s=bcde28add254c5f5)

Add the following API rule to all of the methods:

@request.auth.id != ''

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2Fugq1ng867h2pn05%2Fweb_rtc_7_6pyvjpk8jx.png%3Fthumb%3D&s=3253398284f405e8)

offer_candidates

Create a new collection named offer_candidates with the following columns:

Column Name

Column Type

Column Settings

call_id

Relation

Non empty, calls, Cascade delete is true

data

JSON

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2F488t72n0h2t2623%2Fweb_rtc_8_c1ecscf02n.png%3Fthumb%3D&s=2cc6501104d1e78a)

Add the following API rule to all of the methods:

@request.auth.id != ''

answer_candidates

Create a new collection named answer_candidates with the following columns:

Column Name

Column Type

Column Settings

call_id

Relation

Non empty, calls, Cascade delete is true

data

JSON

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2F0026839i7759o09%2Fweb_rtc_9_8urvznju5m.png%3Fthumb%3D&s=e52ac44c86d308b9)

Add the following API rule to all of the methods:

@request.auth.id != ''

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2F406zf6e649j6m7k%2Fweb_rtc_10_rj34gi9mwc.png%3Fthumb%3D&s=5f7e87d745abd881)

users

For demo purposes we will not be including an auth form for the user, but to make the example simple create a new user with the same login info for the admin.

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2Fy0w1qe8tz830220%2Fweb_rtc_11_a359eqpxdy.png%3Fthumb%3D&s=186d7e29c94e9e8a)

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2Fvxze4jkkk5b4o3q%2Fweb_rtc_12_m6rwgbmoum.png%3Fthumb%3D&s=6288ad5930376386)

Setting up the client

Navigate to the directory and run the following commands to get started:

npm init -y
npm i -D vite
npm i pocketbase

Update the package.json to be the following:

{
  "name": "webrtc-pocketbase-demo",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "serve": "vite preview"
  },
  "devDependencies": {
    "vite": "^4.5.0"
  },
  "dependencies": {
    "pocketbase": "^0.19.0"
  }
}

If you are in a Git repository update/create the .gitignore to have the following:

node_modules
.DS_Store
dist
dist-ssr
*.local
.pb
.env

HTML

Create index.html and add the following:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="favicon.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>WebRTC Pocketbase Demo</title>
  </head>
  <body>
    <h2>1. Start your Webcam</h2>
    <div class="videos">
      <span>
        <h3>Local Stream</h3>
        <video id="webcamVideo" autoplay playsinline></video>
      </span>
      <span>
        <h3>Remote Stream</h3>
        <video id="remoteVideo" autoplay playsinline></video>
      </span>
    </div>
    <button id="webcamButton">Start webcam</button>
    <h2>2. Create a new Call</h2>
    <button id="callButton" disabled>Create Call (offer)</button>``
    <h2>3. Join a Call</h2>
    <p>Answer the call from a different browser window or device</p>
    <input id="callInput" />
    <button id="answerButton" disabled>Answer</button>
    <h2>4. Hangup</h2>
    <button id="hangupButton" disabled>Hangup</button>
    <script type="module" src="/main.js"></script>
  </body>
</html>

CSS

Create style.css and add the following:

body {
  --text-color: #2c3e50;
  --video-background-color: #2c3e50;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: var(--text-color);
  margin: 80px 10px;
}

video {
  width: 40vw;
  height: 30vw;
  margin: 2rem;
  background: var(--video-background-color);
}

.videos {
  display: flex;
  align-items: center;
  justify-content: center;
}

JS

Create main.js and add the following:

import "./style.css";

import PocketBase from "pocketbase";

const pb = new PocketBase("http://127.0.0.1:8090");

const calls = pb.collection("calls");
const offerCandidates = pb.collection("offer_candidates");
const answerCandidates = pb.collection("answer_candidates");

const webcamButton = document.getElementById("webcamButton");
const webcamVideo = document.getElementById("webcamVideo");
const callButton = document.getElementById("callButton");
const callInput = document.getElementById("callInput");
const answerButton = document.getElementById("answerButton");
const remoteVideo = document.getElementById("remoteVideo");
const hangupButton = document.getElementById("hangupButton");

const auth = await pb
  .collection("users")
  .authWithPassword(
    import.meta.env.VITE_POCKETBASE_USERNAME,
    import.meta.env.VITE_POCKETBASE_PASSWORD
  );
const userId = auth.record.id;
const iceServers = await pb.collection("ice_servers").getFullList();

const servers = {
  iceServers: [{ urls: iceServers.map((e) => e.url) }],
  iceCandidatePoolSize: 10,
};

const pc = new RTCPeerConnection(servers);
let localStream = null;
let remoteStream = null;

webcamButton.onclick = async () => {
  localStream = await navigator.mediaDevices.getUserMedia({
    video: true,
    audio: true,
  });
  remoteStream = new MediaStream();

  localStream.getTracks().forEach((track) => {
    pc.addTrack(track, localStream);
  });

  pc.ontrack = (event) => {
    const stream = event.streams[0];
    stream.getTracks().forEach((track) => {
      remoteStream.addTrack(track);
    });
  };

  webcamVideo.srcObject = localStream;
  remoteVideo.srcObject = remoteStream;

  callButton.disabled = false;
  answerButton.disabled = false;
  webcamButton.disabled = true;
};

callButton.onclick = async () => {
  const call = await calls.create({
    user_id: userId,
  });
  const callId = call.id;

  callInput.value = callId;

  pc.onicecandidate = (event) => {
    event.candidate &&
      offerCandidates.create({
        call_id: callId,
        data: event.candidate.toJSON(),
      });
  };

  const offerDescription = await pc.createOffer();
  await pc.setLocalDescription(offerDescription);

  const offer = {
    sdp: offerDescription.sdp,
    type: offerDescription.type,
  };

  await calls.update(callId, { offer });

  calls.subscribe(callId, (e) => {
    const data = e.record;
    if (!pc.currentRemoteDescription && data?.answer) {
      const answerDescription = new RTCSessionDescription(data.answer);
      pc.setRemoteDescription(answerDescription);
    }
  });

  answerCandidates.subscribe("*", (e) => {
    if (e.action === "create") {
      if (e.record?.call_id === callId) {
        const data = e.record.data;
        const candidate = new RTCIceCandidate(data);
        pc.addIceCandidate(candidate);
      }
    }
  });

  hangupButton.disabled = false;
};

answerButton.onclick = async () => {
  const callId = callInput.value;
  const call = await calls.getOne(callId);

  pc.onicecandidate = (event) => {
    event.candidate &&
      answerCandidates.create({
        call_id: call.id,
        data: event.candidate.toJSON(),
      });
  };

  const offerDescription = call.offer;
  const remoteDescription = new RTCSessionDescription(offerDescription);
  await pc.setRemoteDescription(remoteDescription);

  const answerDescription = await pc.createAnswer();
  await pc.setLocalDescription(answerDescription);

  const answer = {
    type: answerDescription.type,
    sdp: answerDescription.sdp,
  };

  await calls.update(call.id, { answer });

  offerCandidates.subscribe("*", async (e) => {
    if (e.record?.call_id === call.id) {
      if (e.action === "create") {
        const data = e.record.data;
        const candidate = new RTCIceCandidate(data);
        await pc.addIceCandidate(candidate);
      } else if (e.action === "delete") {
        await offerCandidates.unsubscribe();
        window.location.reload();
      }
    }
  });
};

hangupButton.onclick = async () => {
  const callId = callInput.value;
  pc.close();
  await calls.unsubscribe(callId);
  await calls.delete(callId);
  await answerCandidates.unsubscribe();
  window.location.reload();
};

Running the example

Run the following command to start the client (make sure the server is running in a separate terminal client):

npm run dev

If successful you should see the following:

  VITE v4.5.0  ready in 547 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help

Open up two browsers with the same url:

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2F05p16897oei07x6%2Fweb_rtc_13_9b6nwkhq3i.png%3Fthumb%3D&s=c37fa04faa0e9b8c)

In the first window click Start webcam and then Create Call (offer).

This will ask for camera permission and then generate a new id and add it to the Join a Call text field.

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2Fj3436r8199114m1%2Fweb_rtc_14_rat2efjyy3.png%3Fthumb%3D&s=41657a629a1e1ab5)

Copy the new id and paste it in the second window field and click Start webcam.

![](/api/image-proxy?url=https%3A%2F%2Frodydavis.com%2F_%2F..%2Fapi%2Ffiles%2Fpbc_2708086759%2F4nlh0c1566v17pn%2Fweb_rtc_15_438n00ql98.png%3Fthumb%3D&s=a4b310369945afc8)

Then click Hangup when you are done with the call 🎉.

Conclusion

You can find the source code here.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.81%
按下载量换算158

Claude

30.07%
按下载量换算133

Cursor

18.5%
按下载量换算82

Gemini CLI

8.54%
按下载量换算38

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

未通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills