c++ - Boost Async Server 基于会话对象处理多个客户端
问题描述
我正在编写一个异步服务器,连接到服务器的客户端将请求多种类型的数据,我的意思是说......假设服务器是这里的餐厅
客户端 1 将连接并请求披萨,需要 10 秒响应
服务器将确认请求并且必须在 data[pizza] 准备好时响应/回调
Client 2 将连接并请求 Burger,需要 3 秒才能响应
服务器将确认请求并且必须在 data[burger] 准备好时响应/回调
我该如何设计这个案例,或者在我的服务器代码中处理它???
通过给出的例子
https://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/example/ssl/server.cpp
new_session = new session(io_service_, context_);
acceptor_.async_accept(new_session->socket(),
boost::bind(&server::handle_accept, this, new_session,
boost::asio::placeholders::error)); ```
1) So the multiple clients can be hanlded by multiple session object that are getting created. Is the statement correct ?
2) Does server will keep each new_session object in a list to differentiate the clients SO that it will respond to them based on the type of request
解决方案
推荐阅读
- bitnami - 如何添加虚拟主机而无需在 bitnami 服务器中重新启动 apache
- scala - 在akka-streams中为JsonFraming添加EOF时添加自定义逻辑/回调/处理程序
- php - 重定向回起始页面时如何显示在下拉菜单中选择的原始名称?
- javascript - Vue 页面中的 Chart.js 抛出错误:不要在突变处理程序之外改变 vuex 存储状态
- typescript - 如何在 react-admin 中动态添加请求标头?
- javascript - 我想上传到 aws s3 存储桶,但我的代码显示此错误
- docker - 通过 nginx 访问多个 nexus 托管的 repos
- flutter - 发现任务配置存在一些问题,没有为属性“signingConfig.keyAlias”指定值。扑
- java - 错误:java.lang.IllegalArgumentException 无法使用 Graphql 在 Spring Boot 中转换 LocalDate?
- javascript - 在按钮单击 Javascript 时播放交替音频