qicosmos / rest_rpc

modern C++(C++11), simple, easy to use rpc framework
MIT License
1.66k stars 365 forks source link

请问服务端有办法获取客户端调用的ip地址吗 #80

Open marchlion1 opened 1 year ago

qicosmos commented 1 year ago

有接口 https://github.com/qicosmos/rest_rpc/blob/master/include/rest_rpc/connection.h#L80

marchlion1 commented 1 year ago

请问我使用rpc_conn 类调用 remote_address 没有成功,报错如下

/routing-service/server/RoutingService/RoutinServiceImplNew.cpp:17:27: error: 'using rpc_conn = class std::weak_ptr' {aka 'class std::weak_ptr'} has no member named 'remote_address'

17 | std::string id = conn.remote_address();

或者:conn->remote_address也没有成功

可这个应该是一个conn 的一个weak_ptr ,应该能调用connection 的方法

应该如何解决

发件人: @. @.> 代表 qicosmos 发送时间: 2022年9月10日 19:25 收件人: qicosmos/rest_rpc @.> 抄送: marchlion1 @.>; Author @.***> 主题: Re: [qicosmos/rest_rpc] 请问服务端有办法获取客户端调用的ip地址吗 (Issue #80)

有接口 https://github.com/qicosmos/rest_rpc/blob/master/include/rest_rpc/connection.h#L80

— Reply to this email directly, view it on GitHub https://github.com/qicosmos/rest_rpc/issues/80#issuecomment-1242709262 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AL2IXZ6UICOWYX3UTUSX7UDV5RVY5ANCNFSM6AAAAAAQJEWSLM . You are receiving this because you authored the thread.Message ID: @.***>

qicosmos commented 1 year ago

https://github.com/qicosmos/rest_rpc/blob/master/examples/server/main.cpp#L78 先看看怎么正确拿到connection