Skip to content

modern C++(C++11), simple, easy to use rpc framework

License

Notifications You must be signed in to change notification settings

sleepy-zeo/rest_rpc

 
 

Repository files navigation

rest_rpc

It's so easy to love RPC

subscribe and publish

整个流程完成了一个client向另外的一个或多个clients发送数据的功能

client1 subscribe

client1.subscribe("key", "048a796c8a3c6a6b7bd1223bf2c8cee05232e927b521984ba417cb2fca6df9d1", [](...){});

client2 subscribe same or different key-token

client2.subscribe("key", "048a796c8a3c6a6b7bd1223bf2c8cee05232e927b521984ba417cb2fca6df9d1", [](...){});

server

1. 存储token "048a796c8a3c6a6b7bd1223bf2c8cee05232e927b521984ba417cb2fca6df9d1"
2. 存储key-token: connection1(client1保持的连接)
3. 存储key-token: connection2(client2保持的连接)

server register publish

server.register_handler("publish_by_token", [&server](rpc_conn conn, std::string key, std::string token, std::string val){});
具体的回调行为是找到key-token对应的所有的clients
然后针对每个client都是response(0, std::move(result), request_type::subscribe);

client call

当clientX call<>("publish_by_token", key, token, data)时候
server会调用publish_by_token对应的回调函数,也就是所有subscribe key-token的clients都会收到data这个数据

比如clientX call<>("publish_by_token", "key", "048a796c8a3c6a6b7bd1223bf2c8cee05232e927b521984ba417cb2fca6df9d1", data);
那么client1和client2都会收到clientX发来的数据data

Others

To be continue...

About

modern C++(C++11), simple, easy to use rpc framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 95.3%
  • C 4.7%