Download the PHP package kitty/websocket without Composer

On this page you can find all versions of the php package kitty/websocket. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package websocket

Laravel-WebSocket

Laravel项目量身开WebSocke服务驱动器,可以让您快速部署websocket服务程序,该程序具有以下特点,

(1)开箱即用,配置简单

(2)丰富的api。

(3)强大的SocketManager进程管理控制

(4)全局通信组件,使WebSocket服务与Http服务完美结合

一、安装与配置:

(一)安装

(二)配置

​ 在命令行输入php artisan vendor:publish 就会将配置文件提取至/config/websocket.php,如下:

​ 可以看到配置中的adressport,选项默认指向了env,所以你还可以通过在env 文件中 SOCKET_ADDRESS与SOCKET_PORT来配置服务地址与端口。

(三)添加服务提供者

​ 修改/config/app.php文件下的'providers'数组内如下:

二、开启服务

​ 上述命令会开启一个常驻内存的socket进程 ,并监听上一步骤配置项的地址与端口,来处理websocket请求。

​ 测试:kitty/websocket 提供了一个简单的demo 开启服务成功后可以在浏览器访问localhost/kitty/websocket/demo 进行测试

三、创建事件响应器

​ 1、一旦服务启动,每个socket请求都将会被kitty/websocket响应到\App\Job\WebSocketJob类中,所以你可以在这个类中,按照你的业务逻辑来处理这些请求。

​ 2、你可以通过命令php artisan socket:make job 来快速的在app/Jobs目录下创建事件处理类WebSocketJob ,kitty/websocket已经为你解决了继承关系,并生成了示例代码。

四、事件响应

​ 如上所述,kitty/websocket的事件响应代码都放置在了app/Jobs/WebSocketJob.php中。共包括五种事件类型:

​ 1、用户建立连接时,响应 login() 事件;

​ 2、用户断开连接时,响应logout()事件;

​ 3、用户发送消息时,响应massage()事件;

​ 4、接收到管理进程(SocketManager)指令时,响应manager()事件;

​ 5、timer()事件,用来响应定时任务

五、进程管理(SoketManager)

​ 进程管理是kitty/websocket的特色功能,提供了强大进程管理、进程监控的能力,除此之外,借助SoketManager还可以在项目任意一处代码中实现WebServer与SocketServer的通信。

​ 控制台是webSocket开发调试利器,可以监控和干预服务进程,输入上述命令,进入控制台,即进入指令输入模式,

​ 指令是SocketManager 与服务进程通信的命令文本,格式如下

​ send 你好 --id 12 //向id为12的客户端发送‘你好’

​ {主指令} {主指令参数1} {主指令参数2} {主指令参数...} {副指令(以--开头)} {副指令参数} {选项1(以-开头)} {选项...}

​ 进程管理控制台常用指令:

六、API

(一)Socket API (只能在事件响应器(\App\Job\WebSocketJob)中使用)

​ 1、where( $key,$ $value1$, $[value2]$ ) //筛选指定条件的用户放置于用户栈;通常配合send(),close()使用方法与Laravel Collection的where一致

​ 2、send( $message$ ) //向用户栈所有客户端发送信息 在where之后调用

​ 3、close( ) //关闭用户栈所有客户端,在where之后调用

​ 上述几条用法示例 :

​ 4、sendById( $id$, $message$ ) // 向指定id 发送信息

​ 5、getAllUser( ) //获取当前所有连接用户

​ 6、getCcurrentUsers( ) //获取当前用户栈中所有用户

​ 7、user( $ id$ ) //返回给定id的用户

​ 8、addAttributeToUser( $id$, (array) $attr$ ) //向给定id的用户属性表中添加属性(键值对)

​ 9、broadcast( $message$ ) //向所有连接用户发送信息

​ 10、默认用户属性 :

(二)Globle API(在全文使用,由SocketManager提供)

​ 上文的第五条中介绍了SocketManager指令发送,除了在命令行中输入指令,还可以调用Kitty\WebSocket\SocketManager 中的send()方法向服务进程发送一条指令,实现在任何场景下与服务进程通信,send只接受一个字符串参数作为指令码,指令码的写法上文中已经介绍,这里不再赘述。

​ 示例:


All versions of websocket with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kitty/websocket contains the following files

Loading the files please wait ....