• Stars
    star
    334
  • Rank 126,264 (Top 3 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 10 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sdk For GatewayWorker

GatewayClient

GatewayWorker1.0请使用1.0版本的GatewayClient

GatewayWorker2.0.1-2.0.4请使用2.0.4版本的GatewayClient

GatewayWorker2.0.5-2.0.6版本请使用2.0.6版本的GatewayClient

GatewayWorker2.0.7版本请使用 2.0.7版本的GatewayClient

GatewayWorker3.0.0-3.0.7版本请使用 3.0.0版本的GatewayClient

GatewayWorker3.0.8及以上版本请使用 3.0.13版本的GatewayClient

注意:GatewayClient3.0.0以后支持composer并加了命名空间GatewayClient

如何查看GatewayWorker版本请点击这里

安装

方法一

composer require workerman/gatewayclient

使用时引入vendor/autoload.php 类似如下:

use GatewayClient\Gateway;
require_once '真实路径/vendor/autoload.php';

方法二 下载源文件到任意目录,手动引入 GatewayClient/Gateway.php, 类似如下:

use GatewayClient\Gateway;
require_once '真实路径/GatewayClient/Gateway.php';

使用

// GatewayClient 3.0.0版本以后加了命名空间
use GatewayClient\Gateway;

// composer安装
require_once '真实路径/vendor/autoload.php';

// 源文件引用
//require_once '真实路径/GatewayClient/Gateway.php';

/**
 * === 指定registerAddress表明与哪个GatewayWorker(集群)通讯。===
 * GatewayWorker里用Register服务来区分集群,即一个GatewayWorker(集群)只有一个Register服务,
 * GatewayClient要与之通讯必须知道这个Register服务地址才能通讯,这个地址格式为 ip:端口 ,
 * 其中ip为Register服务运行的ip(如果GatewayWorker是单机部署则ip就是运行GatewayWorker的服务器ip),
 * 端口是对应ip的服务器上start_register.php文件中监听的端口,也就是GatewayWorker启动时看到的Register的端口。
 * GatewayClient要想推送数据给客户端,必须知道客户端位于哪个GatewayWorker(集群),
 * 然后去连这个GatewayWorker(集群)Register服务的 ip:端口,才能与对应GatewayWorker(集群)通讯。
 * 这个 ip:端口 在GatewayClient一侧使用 Gateway::$registerAddress 来指定。
 * 
 * === 如果GatewayClient和GatewayWorker不在同一台服务器需要以下步骤 ===
 * 1、需要设置start_gateway.php中的lanIp为实际的本机内网ip(如不在一个局域网也可以设置成外网ip),设置完后要重启GatewayWorker
 * 2、GatewayClient这里的Gateway::$registerAddress的地址填写实际运行Register的服务器ip和端口
 * 3、需要开启GatewayWorker所在服务器的防火墙,让以下端口可以被GatewayClient所在服务器访问,
 *    端口包括Rgister服务的端口以及start_gateway.php中lanIp与startPort指定的几个端口
 *
 * === 如果GatewayClient和GatewayWorker在同一台服务器 ===
 * GatewayClient和Register服务都在一台服务器上,ip填写127.0.0.1及即可,无需其它设置。
 **/
Gateway::$registerAddress = '127.0.0.1:1236';

// GatewayClient支持GatewayWorker中的所有接口(Gateway::closeCurrentClient Gateway::sendToCurrentClient除外)
Gateway::sendToAll($data);
Gateway::sendToClient($client_id, $data);
Gateway::closeClient($client_id);
Gateway::isOnline($client_id);
Gateway::bindUid($client_id, $uid);
Gateway::isUidOnline($uid);
Gateway::getClientIdByUid($uid);
Gateway::unbindUid($client_id, $uid);
Gateway::sendToUid($uid, $dat);
Gateway::joinGroup($client_id, $group);
Gateway::sendToGroup($group, $data);
Gateway::leaveGroup($client_id, $group);
Gateway::getClientCountByGroup($group);
Gateway::getClientSessionsByGroup($group);
Gateway::getAllClientCount();
Gateway::getAllClientSessions();
Gateway::setSession($client_id, $session);
Gateway::updateSession($client_id, $session);
Gateway::getSession($client_id);

More Repositories

1

workerman

An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols.
PHP
11,067
star
2

phpsocket.io

A server side alternative implementation of socket.io in PHP based on workerman.
PHP
2,284
star
3

webman

Probably the fastest PHP web framework in the world.
PHP
2,126
star
4

workerman-todpole

HTML5+WebSocket+PHP(Workerman) , rumpetroll server writen using php
PHP
1,844
star
5

workerman-chat

Websocket chat room written in PHP based on workerman.
PHP
1,185
star
6

GatewayWorker

Distributed realtime messaging framework based on workerman.
PHP
1,007
star
7

web-msg-sender

Web message pusher written in PHP based on workerman.
PHP
922
star
8

live-camera

Live camera based on HTML5+Canvas+Websocket+PHP (Workerman).
PHP
458
star
9

BrowserQuest-PHP

BrowserQuest server in PHP base on workerman. A PHP/HTML5/JavaScript multiplayer game experiment.
PHP
376
star
10

workerman-statistics

一个分布式统计监控系统 包含PHP客户端 、服务端
PHP
350
star
11

workerman-thrift

Thrift RPC for php based on workerman.
PHP
274
star
12

workerman-jsonrpc

workerman作为进程管理器,json作为协议的远程服务调用的框架
PHP
251
star
13

workerman-webrtc

php webrtc demo based on workerman
JavaScript
251
star
14

live-ascii-camera

利用HTML5将摄像头视频转换为ascii字符,通过websocket实时传输给其它页面。服务端使用workerman
PHP
215
star
15

php-socks5

socks5 proxy written in PHP based on workerman.
PHP
208
star
16

mqtt

Asynchronous MQTT client for PHP based on workerman.
PHP
203
star
17

php-http-proxy

HTTP proxy written in PHP based on workerman.
PHP
201
star
18

phptty

Share your terminal as a web application. PHP terminal emulator based on workerman.
PHP
173
star
19

workerman-vmstat

在浏览器里面显示以更友好的方式实时显示vmstats信息,包括内存、IO、cpu等信息
PHP
160
star
20

channel

Interprocess communication component for workerman
PHP
136
star
21

workerman-flappy-bird

flappy bird 多人在线版
PHP
119
star
22

webman-framework

webman-framework
PHP
116
star
23

workerman-for-win

workerman 3.x windows 版本(目前linux版本已经兼容windows,此版本不再维护)
PHP
109
star
24

workerman-queue

workerman 消息队列
PHP
107
star
25

GlobalData

进程间变量共享组件,用于分布式数据共享
PHP
73
star
26

workerman-todpole-web

小蝌蚪互动聊天室-适合虚拟空间使用(后端直接与workerman主机通讯。请保留页面上workerman的相关链接)
JavaScript
73
star
27

workerman-filemonitor

监控文件更新并自动reload workerman
PHP
67
star
28

workerman-manual

Workerman manual
PHP
65
star
29

crontab

A crontab written in PHP based on workerman
PHP
60
star
30

mysql

Long-living MySQL connection for daemon.
PHP
55
star
31

workerman-chat-for-win

workerman-chat windows版本
PHP
48
star
32

http-client

Asynchronous http client for PHP based on workerman.
PHP
47
star
33

rabbitmq

Asynchronous rabbitmq client for PHP based on workerman.
PHP
35
star
34

redis-queue

Message queue system written in PHP based on workerman and backed by Redis.
PHP
35
star
35

workerman-todpole-for-win

workerman-todpole-for-win
PHP
25
star
36

workerman.net

workerman.net主页源代码
PHP
25
star
37

phpsocket.io-emitter

PHP
23
star
38

workerman-MT

workerman多线程版本,同时支持Linux平台与Windows平台,接口与原Linux多进程版本兼容
PHP
22
star
39

redis

Asynchronous redis client for PHP based on workerman.
PHP
18
star
40

workerman-filemonitor-inotify

workerman文件监控并自动reload inotify版本
PHP
17
star
41

workerman-manual-zh

workerman中文手册
17
star
42

web-msg-sender-for-win

web-msg-sender for win
PHP
17
star
43

GatewayWorker-for-win

GatewayWorker for windows.
PHP
16
star
44

global-timer

Distributed timer for workerman.
PHP
15
star
45

phpsocket.io-for-win

PHP
12
star
46

webserver-example

PHP
10
star
47

stomp

Asynchronous Stomp client for PHP based on workerman.
PHP
8
star
48

tcp-proxy-demo

一个tcp代理服务器的demo
PHP
8
star
49

en.workerman.net

en.workerman.net
PHP
4
star
50

workerman-teach

PHP
4
star
51

gateway-doc

GatewayWorker manual
3
star