-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websocket sample #26
Comments
$app = AppFactory::createBase('0.0.0.0', 9501);
$app->config(['server.servers.1' => [
'name' => 'ws',
'type' => Server::SERVER_WEBSOCKET,
'host' => '0.0.0.0',
'port' => 9502,
'sock_type' => SWOOLE_SOCK_TCP,
'callbacks' => [
Event::ON_HAND_SHAKE => [\Hyperf\WebSocketServer\Server::class, 'onHandShake'],
Event::ON_MESSAGE => [\Hyperf\WebSocketServer\Server::class, 'onMessage'],
Event::ON_CLOSE => [\Hyperf\WebSocketServer\Server::class, 'onClose'],
],
],
]);
$app->run(); 记得先安装 |
你好
你好,是否能提供更详细的实例 use Hyperf\Nano\Factory\AppFactory;
use Hyperf\Server\Server;
use Hyperf\Server\Event;
require_once __DIR__ . '/vendor/autoload.php';
$app = AppFactory::createBase('0.0.0.0', 9503);
$app->config(['server.servers.1' => [
'name' => 'ws',
'type' => Server::SERVER_WEBSOCKET,
'host' => '0.0.0.0',
'port' => 9502,
'sock_type' => SWOOLE_SOCK_TCP,
'callbacks' => [
Event::ON_HAND_SHAKE => [\Hyperf\WebSocketServer\Server::class, 'onHandShake'],
Event::ON_MESSAGE => [\Hyperf\WebSocketServer\Server::class, 'onMessage'],
Event::ON_CLOSE => [\Hyperf\WebSocketServer\Server::class, 'onClose'],
],
],
]);
$app->run(); 我在使用上述代码时运行服务正常,但网页端建立链接时报错: [DEBUG] WebSocket: fd[4] start a handshake request. |
好的,非常感谢 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, how can I make websocket working on Nano? An example please and thank you.
The text was updated successfully, but these errors were encountered: