sowe/peerserver 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sowe/peerserver

Composer 安装命令:

composer create-project sowe/peerserver

包简介

PHP Socket.io server for WebRTC signaling

README 文档

README

PHP Socket.io server for WebRTC signaling.

Client: https://github.com/jsanahuja/peer-client

Demo: https://peer-demo.sowecms.com/

Install

Clone both client and server and install dependencies.

git clone https://github.com/jsanahuja/php-peer-server.git
git clone https://github.com/jsanahuja/peer-client.git
cd php-peer-server 
composer install
cd ../peer-client
npm install
npm run build

Create your server configuration file

cd ../php-peer-server
cp config.example.php config.php

Generate your Keychain private key:

php make_keychain.php

Result example: 1949e2278ea5767099e592ae8dd15677ecf851efd177a1f0fb1d44e8e79231f5

Place the result in the constant KEYCHAIN_PK defined in the config.php file we just created. Set also the absolute path to your CERT_CA and CERT_KEY files. You can play with the other constant values but it should be good to go. Note that if you want to change the PORT you will have to change it in the peer-client too.

Start the server as a daemon

php server.php start -d

Do not forget to open/whitelist the PORT or the server won't be accessible. For example with firewalld you would do:

firewall-cmd --zone=public --permanent --add-port=8999/tcp
firewall-cmd --reload

Note: The HTTP server should be pointing to the peer-client folder.

Management

Here you can see a list of the available commands: https://github.com/walkor/Workerman#available-commands

Server actions

The following is the list of events you can send to the server. For example socket.emit('join', 'a68ca609389b6ba7f0766b9ed1bfd8ca')

create(name, password) creates a room.

join(roomId, password) joins a room.

leave() leaves the current room.

kick(userId) kicks an user from the room. Can only be used by the creator.

ban(userId) bans an user from the room. Can only be used by the creator.

unban(userId) unbans an user from the room. Can only be used by the creator.

message(msg) sends a message to the current room.

toggle(resource) toggles a resource. The resources are 'video', 'microphone' and 'audio'.

candidate(callId, candidate) sends a candidate.

offer(callId, offer) sends an offer. Must have been requested with the call event.

answer(callId, answer) sends an answer. Must have been requested with the offer event.

Server responses

The following are the events the server will trigger.

created(roomId) confirms you created a room.

joined(roomId) confirms you joined the room.

left(roomId) confirms you left the room.

kicked notifies that you have been kicked from the room.

banned notifies that you have been banned from the room.

unbanned notifies that you have been unbanned from a room.

call(callId) requests an offer for the call

offer(callId, offer) sends and offer and requires an answer

answer(callId, answer) sends an answer to the offer

hangup(callId) notifies that the call was closed

Also the error events:

join_alreadyin notifies you can't join the room because you're already in.

join_wrongpass notifies you can't join the room because the password provided is wrong.

join_full notifies you can't join the room because it is full.

join_banned notifies you can't join the room because you are banned.

kick_noprivileges notifies you don't have enough privileges to kick in the current room.

kick_notin notifies that the user you tried to kick is no longer in the room.

ban_noprivileges notifies you don't have enough privileges to ban in the current room.

ban_already notifies that the user you tried to ban is already banned.

unban_noprivileges notifies you don't have enough privileges to unban in the current room.

unban_notbanned notifies you have tried to unban an user that wasn't banned.

And the room events:

r_message(userId, message) someone in your room sent a text message in your room.

r_resource(userId, resource, status) someone in your room toggled the status of one of its resources.

r_joined(userId) an user joined your room.

r_left(userId) an user left your room.

r_kicked(userId) an user was kicked out of your room.

r_banned(userId) an user from your room was banned.

r_unbanned(userId) an user has been unbanned.

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 2
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固