swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 788 forks source link

websocket获取ip问题 #1405

Closed zarte closed 3 years ago

zarte commented 3 years ago

onOpen 中可以使用getHeader获取x-forwarded-for
对象为 Swoft\Http\Message\Request;

但是接收消息方法中就无法获取了
对象为 Swoft\WebSocket\Server\Message\Request;

inhere commented 3 years ago

接收消息方法中 可以通过上下文对象拿到开始请求的 Swoft\Http\Message\Request 对象。