Git Product home page Git Product logo

swoole-websocket-and-tcp-and-udp's Introduction

swoole websocket and tcp and udp

介绍

一个基于swoole的封装程序

实例

$config = [
    'timezone'            => 'Asia/Shanghai',
    'tick_interval_timer' => 30, //秒
    'websocket'           => [
        'enable'  => true,
        'host'    => '0.0.0.0',
        'port'    => '9000',
        'type'    => SWOOLE_SOCK_TCP,
        'setting' => [
            'daemonize'       => false,
            'task_worker_num' => 1,
        ],
        'handler' => \swoole_websocket_and_tcp_and_udp_test\webscoket::class,
    ],
    'http'                => [
        'enable'  => true,
        'host'    => '0.0.0.0',
        'port'    => '9001',
        'type'    => SWOOLE_SOCK_TCP,
        'setting' => [],
        'handler' => \swoole_websocket_and_tcp_and_udp_test\http::class,
    ],
    'tcp'                 => [
        'enable'  => true,
        'host'    => '0.0.0.0',
        'port'    => '9002',
        'type'    => SWOOLE_SOCK_TCP,
        'setting' => [
            'open_eof_check'           => true,
            'package_eof'              => "\r\n",
            'dispatch_mode'            => 2,
            'heartbeat_check_interval' => 30,
            'heartbeat_idle_time'      => 60,
        ],
        'handler' => \swoole_websocket_and_tcp_and_udp_test\tcp::class,
    ],
    'udp'                 => [
        'enable'  => true,
        'host'    => '0.0.0.0',
        'port'    => '9003',
        'type'    => SWOOLE_SOCK_UDP,
        'setting' => [
            'open_eof_check' => true,
            'package_eof'    => "\r\n",
        ],
        'handler' => '',
    ],
];

$server = new \swoole_websocket_and_tcp_and_udp\Server($config);
$server->run();

任务

  • 监听websocket
  • 监听http
  • 监听tcp
  • 监听udp
  • 混合监听

感谢

laravel-s项目给予很大的灵感,谢谢

swoole-websocket-and-tcp-and-udp's People

Contributors

flxxyz avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.