hyperf / hyperf/socketio-server

事件回调的连接上下文中获取不到原始请求对象

オープン
#17 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
PHP
スター
26
フォーク
6
PR マージ指標
30日以内にマージされた PR はありません

説明

代码如下:
```
/**
* @Event("connect")
*/
public function onConnect(Socket $socket)
{
$request = \Hyperf\WebSocketServer\Context::get(
Psr\Http\Message\ServerRequestInterface::class
);
var_dump($request);
return;
}
```
打印结果为null,在`onHandShake`回调的`initRequest`方法中可以正常打印出结果
```
/**
* Initialize PSR-7 Request.
*/
protected function initRequest(SwooleRequest $request): ServerRequestInterface
{
Context::set(ServerRequestInterface::class, $psr7Request = Psr7Request::loadFromSwooleRequest($request));
WsContext::set(ServerRequestInterface::class, $psr7Request);
var_dump(WsContext::get(ServerRequestInterface::class));
return $psr7Request;
}
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start by comparing the onConnect callback with the onHandShake initRequest method shown in the report, tracing where ServerRequestInterface is stored and retrieved from Context. Verify the callback lifecycle and reproduce the null value; done means the original request is available in the connect context or the issue clearly documents the supported limitation.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php
領域
backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。