Added websocket server.

This commit is contained in:
李铭昕 2019-06-21 14:27:50 +08:00
parent 0da96be9ed
commit 5befd1963a
4 changed files with 117 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
namespace Hyperf\Contract;
use Swoole\WebSocket\Server;
use Swoole\Http\Request;
use Swoole\Websocket\Frame;
interface WebSocketServerInteface
{
public function onOpen(Server $server, Request $request): void;
public function onMessage(Server $server, Frame $frame): void;
public function onClose(Server $server, int $fd, int $reactorId): void;
}

View File

@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) Hyperf
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,59 @@
{
"name": "hyperf/websocket-server",
"description": "A websocket server library for Hyperf.",
"license": "MIT",
"keywords": [
"php",
"swoole",
"hyperf",
"websocket"
],
"support": {
},
"require": {
"php": ">=7.2",
"ext-swoole": ">=4.3",
"hyperf/contract": "~1.0.0",
"hyperf/server": "~1.0.0",
"hyperf/utils": "~1.0.0",
"psr/container": "^1.0",
"psr/event-dispatcher": "^1.0",
"psr/log": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.9",
"malukenho/docheader": "^0.1.6",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.0"
},
"suggest": {
},
"autoload": {
"files": [
],
"psr-4": {
"Hyperf\\WebSocketServer\\": "src"
}
},
"autoload-dev": {
"psr-4": {
}
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"hyperf": {
"config": "Hyperf\\WebSocketServer\\ConfigProvider"
}
},
"bin": [
],
"scripts": {
"cs-fix": "php-cs-fixer fix $1",
"test": "phpunit --colors=always"
}
}

View File

@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
namespace Hyperf\WebSocketServer;
use Hyperf\Contract\MiddlewareInitializerInterface;
class Server implements MiddlewareInitializerInterface
{
public function initCoreMiddleware(string $serverName): void
{
// TODO: Implement initCoreMiddleware() method.
}
}