octamp/wamp

WAMP 路由器

维护者

详细信息

github.com/octamp/wamp

源代码

问题

v1.2.0-ALPHA2 2024-09-21 14:43 UTC

This package is auto-updated.

Last update: 2024-09-21 14:45:39 UTC


README

Octamp WAMP 是可扩展的 WAMP 协议的路由器实现。

该实现使用了 PHP OpenSwoole。

目前,为此适配器使用的软件是 Redis。

为什么使用 Octamp WAMP

Octamp WAMP 是使用 PHP 和 OpenSwoole 创建的,而不是使用 Ratchet / React PHP。

Octamp WAMP 还支持通过 Redis 实现的水平扩展。

会话数据和 WAMP 数据将保存在 Redis 中,以便所有节点/服务器都可以访问。

与其他实现比较

概要

Octamp WAMP 目前使用 基本概要和高级概要以及 WAMP Proto 进行实现。

如何使用

先决条件

  • PHP 8.2
  • 具有 Pub/Sub 的 Redis
  • OpenSwoole

安装

composer create-project octamp/wamp ./wamp
cd ./wamp

这将在 wamp 文件夹中创建项目

您可以更新文件 /configs/adapter.yml 或将其复制到不同的文件

并更新配置

adapter:
  type: redis
  host: 0.0.0.0
  port: 6379
#  -- Uncomment the auth if you need username and password
#  auth:
#    username:
#    password:
#
#  -- Uncomment options if you need to include other redis option such as database
  options:
    database: 0

您可以更新文件 /configs/transport.yml 或将其复制到不同的文件

并更新配置

transports:
  - endpoint:
      type: tcp
      port: 8080
    auths:
      - method: anonymous
        type: static

# -- You can add more method, such us the examples below
#    - method: ticket
#      type: dynamic
#      authenticator: testing
#      authenticatorRealm: realm1
#      realms:
#        - realm1
#    - method: wampcra
#      type: static
#      users:
#        - authid: auth
#          secret: qa2/QVmmjSx1JJuyH5EI2gMDQf+ARnfwMcLOpUfln74=
#          role: auth
#          salt: salt1
#          keylen: 32
#          iterations: 1000

您可以更新文件 /configs/realms.yml 或将其复制到不同的文件

并更新配置

realms:
  - name: realm1

将文件 .env 复制到 .env.local

更新必要的数据

TRANSPORT_FILE=/configs/transport.yml
ADAPTER_FILE=/configs/adapter.yml
REALM_FILE=/configs/realms.yml

现在运行 bin/server

php ./bin/server

这将现在运行服务器

Octamp WAMP 功能

  • 高性能 - 使用基于事件驱动、异步、非阻塞 I/O 协程编程模型的 OpenSwoole 网络框架。
  • 可扩展性 - 设计用于水平扩展。
  • WAMP 基本概要功能 - 该项目实现了 WAMP v2 中大部分的基本概要功能。
  • WebSocket 传输 - 目前该项目仅实现 WebSocket 传输。
  • 消息序列化 - 接受 JSON 和 MessagePack。

消息序列化

  • JSON
  • MessagePack

基本概要功能支持

会话

发布和订阅

远程过程调用

其他功能

高级概要功能支持

身份验证

附加身份验证

  • 添加角色检查

RPC 功能

PubSub 功能

其他

待办事项