Title: Can you provide an interface that calls back on the main thread? · Issue #90 · cpp-redis/cpp_redis · GitHub
Open Graph Title: Can you provide an interface that calls back on the main thread? · Issue #90 · cpp-redis/cpp_redis
X Title: Can you provide an interface that calls back on the main thread? · Issue #90 · cpp-redis/cpp_redis
Description: Hello, I am a game server developer. When we use cpp_redis, there will be a need to call back on the main thread. At present, I have sealed it with asio to temporarily meet the needs. Would like to ask if the official can provide such an...
Open Graph Description: Hello, I am a game server developer. When we use cpp_redis, there will be a need to call back on the main thread. At present, I have sealed it with asio to temporarily meet the needs. Would like to...
X Description: Hello, I am a game server developer. When we use cpp_redis, there will be a need to call back on the main thread. At present, I have sealed it with asio to temporarily meet the needs. Would like to...
Opengraph URL: https://github.com/cpp-redis/cpp_redis/issues/90
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Can you provide an interface that calls back on the main thread?","articleBody":"Hello, I am a game server developer. When we use cpp_redis, there will be a need to call back on the main thread.\r\n\r\nAt present, I have sealed it with asio to temporarily meet the needs. Would like to ask if the official can provide such an interface. Or there are others with similar needs.\r\nMy own example: https://github.com/brinkqiang/dmredispp\r\n\r\n```\r\n#include \u003ccpp_redis/cpp_redis\u003e\r\n\r\n#include \u003ciostream\u003e\r\n\r\n#ifdef _WIN32\r\n#include \u003cWinsock2.h\u003e\r\n#endif /* _WIN32 */\r\n#include \"dmevent/dmevent_module.h\"\r\n\r\n\r\nint\r\nmain(void) {\r\n#ifdef _WIN32\r\n //! Windows netword DLL init\r\n WORD version = MAKEWORD(2, 2);\r\n WSADATA data;\r\n\r\n if (WSAStartup(version, \u0026data) != 0) {\r\n std::cerr \u003c\u003c \"WSAStartup() failure\" \u003c\u003c std::endl;\r\n return -1;\r\n }\r\n#endif /* _WIN32 */\r\n\r\n DMEVENT_INIT();\r\n DMEVENT_BEGIN\r\n {\r\n fmt::print(\"-------------------------------------------- -------------------\\n\");\r\n fmt::print(\"{} dmevent loop {} ...\\n\", DMGetExeName(), \"running\");\r\n fmt::print(\"-------------------------------------------- -------------------\\n\");\r\n }\r\n DMEVENT_END;\r\n\r\n\r\n //! Enable logging\r\n cpp_redis::active_logger = std::unique_ptr\u003ccpp_redis::logger\u003e(new cpp_redis::logger);\r\n\r\n cpp_redis::client client;\r\n\r\n client.connect(\"127.0.0.1\", 6379, [\u0026](const std::string\u0026 host, std::size_t port, cpp_redis::client::connect_state status) {\r\n DMEVENT_BEGIN\r\n {\r\n if (status == cpp_redis::client::connect_state::dropped) {\r\n fmt::print(\"client disconnected from {}:{} isMain:{}\\n\", host, port, isMain());\r\n }\r\n }\r\n DMEVENT_END;\r\n });\r\n\r\n int roleid = 0x1234;\r\n // same as client. send({ \"SET\", \"hello\", \"42\" }, ...)\r\n client.set(\"hello\", \"42\", [\u0026](cpp_redis::reply\u0026 reply) {\r\n DMEVENT_BEGIN\r\n {\r\n fmt::print(\"set hello 42: {} roleid: {} isMain:{}\\n\", reply, roleid, isMain());\r\n }\r\n DMEVENT_END;\r\n });\r\n\r\n // same as client. send({ \"DECRBY\", \"hello\", 12 }, ...)\r\n client.decrby(\"hello\", 12, [\u0026](cpp_redis::reply\u0026 reply) {\r\n DMEVENT_BEGIN\r\n {\r\n fmt::print(\"decrby hello 12: {} roleid: {} isMain:{}\\n\", reply, roleid, isMain());\r\n }\r\n DMEVENT_END;\r\n });\r\n\r\n // same as client. send({ \"GET\", \"hello\" }, ...)\r\n client.get(\"hello\", [\u0026](cpp_redis::reply\u0026 reply) {\r\n DMEVENT_BEGIN\r\n {\r\n fmt::print(\"get hello: {} roleid: {} isMain:{}\\n\", reply, roleid, isMain());\r\n }\r\n DMEVENT_END;\r\n });\r\n\r\n // commands are pipelined and only sent when client.commit() is called\r\n client.commit();\r\n\r\n DMEVENT_RUN_UNTIL();\r\n // synchronous commit, no timeout\r\n //client.sync_commit();\r\n\r\n // synchronous commit, timeout\r\n // client.sync_commit(std::chrono::milliseconds(100));\r\n\r\n#ifdef _WIN32\r\n WSACleanup();\r\n#endif /* _WIN32 */\r\n\r\n return 0;\r\n}\r\n```","author":{"url":"https://github.com/brinkqiang","@type":"Person","name":"brinkqiang"},"datePublished":"2022-03-23T10:09:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/90/cpp_redis/issues/90"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2c9d0302-ccf4-b6d0-eea0-83bea46c5133 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D02C:41B52:10145F2:148F332:697548D3 |
| html-safe-nonce | 81523504733500ee7cac5e4725053bb690a4acc5bce48840c53075b4a421170d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDJDOjQxQjUyOjEwMTQ1RjI6MTQ4RjMzMjo2OTc1NDhEMyIsInZpc2l0b3JfaWQiOiI2MDgxNTQ0MjA4MjMxMjU0MjI3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 250361598d97c4fbc35cebc1673469a61986a6807a6d44171cbaa24dfd161d6e |
| hovercard-subject-tag | issue:1177898173 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cpp-redis/cpp_redis/90/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d7062cce51fe48f1016886ea4ec58cdc20832d3188d2b6abd78fe76c4710af85/cpp-redis/cpp_redis/issues/90 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d7062cce51fe48f1016886ea4ec58cdc20832d3188d2b6abd78fe76c4710af85/cpp-redis/cpp_redis/issues/90 |
| og:image:alt | Hello, I am a game server developer. When we use cpp_redis, there will be a need to call back on the main thread. At present, I have sealed it with asio to temporarily meet the needs. Would like to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | brinkqiang |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f |
| turbo-cache-control | no-preview |
| go-import | github.com/cpp-redis/cpp_redis git https://github.com/cpp-redis/cpp_redis.git |
| octolytics-dimension-user_id | 45303665 |
| octolytics-dimension-user_login | cpp-redis |
| octolytics-dimension-repository_id | 158901124 |
| octolytics-dimension-repository_nwo | cpp-redis/cpp_redis |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 38889153 |
| octolytics-dimension-repository_parent_nwo | Cylix/cpp_redis |
| octolytics-dimension-repository_network_root_id | 38889153 |
| octolytics-dimension-repository_network_root_nwo | Cylix/cpp_redis |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 488b30e96dfd057fbbe44c6665ccbc030b729dde |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width