GithubHelp home page GithubHelp logo

zanwebsocketdemo's Introduction

ZanWebSocketDemo

zan php websocket server demo

##如何使用

  1. 安装 zan扩展
  2. 安装composer
  3. 在根目录下执行composer update
  4. 配置php.ini
zanphp.RUN_MODE = test
zanphp.DEBUG = true
  1. 启动http server php bin/websocket
  2. 浏览器打开bin/test.html

##zan框架websocket前后端协议规范 ###请求格式

{
	"path": "/module/controller/action",
	"data": "xxx"
}
  • path: url中的path字段,用于请求路由,websocket可以复用HTTP的路由、filter等功能
  • data: 请求数据

###响应格式

{
	"code": 0,
	"data": "xxx"
}
  • code: 响应码,0表示success,其他值表示错误码
  • data: code为0时代表响应,其他值时表示错误信息

7.测试

启动server: 
    php bin/websocket
启动client:
    cd test
    phpunit --bootstrap bootstrap.php WebSocketTest

8.controller编写 参照示例中的controller实现即可。

zanwebsocketdemo's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.