2017 © Pedro Peláez
 

library newx-server

A server application

image

beansir/newx-server

A server application

  • Tuesday, March 13, 2018
  • by 1052049021@qq.com
  • Repository
  • 0 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

NewX Server

安装说明

使用composer一键安装, (*1)

composer require beansir/newx-server

搭建结构

  • service
    • config
      • config.php
      • database.php
    • WebSocket.php
  • server // 脚本执行文件

创建脚本执行文件server

#!/usr/bin/env php
<?php
defined('PROJECT_PATH') or define('PROJECT_PATH', __DIR__);

require PROJECT_PATH . '/vendor/beansir/newx-server/server';

服务配置文件

server/config.php, (*2)

<?php
return [
    'app' => [
        // 服务器配置
        'tcp' => [
            'host' => '0.0.0.0',
            'port' => 9501
        ],
        'web-socket' => [
            'host' => '0.0.0.0',
            'port' => 9502
        ],
        'http' => [
            'host' => '0.0.0.0',
            'port' => 9503
        ],
    ],
    'database' => [
        // 数据库配置,非必须配置项
        'default' => [
            'host'      => '127.0.0.1',
            'user'      => 'user',
            'password'  => 'password',
            'db'        => 'db',
            'type'      => 'mysqli'
        ],
    ]
];

WebSocket

<?php
namespace service;
class WebSocket extends \newx\server\base\WebSocket
{
    /**
     * 监听客户端连接
     * @param $server
     * @param $request
     */
    public function open($server, $request)
    {
        var_dump($request);
    }

    /**
     * 监听客户端数据
     * @param $server
     * @param $frame
     */
    public function message($server, $frame)
    {
        var_dump($frame);
    }

    /**
     * 监听客户端关闭连接
     * @param $server
     * @param $fd
     */
    public function close($server, $fd)
    {
        var_dump($fd);
    }
}

启动服务

server web-socket

The Versions

13/03 2018

dev-master

9999999-dev

A server application

  Sources   Download

MIT

The Requires

 

by bean

server websocket newx

13/03 2018

v1.1

1.1.0.0

A server application

  Sources   Download

MIT

The Requires

 

by bean

server websocket newx

08/03 2018

v1.0

1.0.0.0

A server application

  Sources   Download

MIT

The Requires

 

by bean

server websocket newx