The architecture of bitshares ap
2018-08-07 本文已影响0人
杨小伟的世界
Local api call
The effect of following line. (fc/tests/api.cpp)
fc::api<calculator> api_calc( std::make_shared<some_calculator>() );
api<calculator> some_calculator
+----------------------+ +----------------------+
|_vtable | _vtable::visit_other( | |
| +------------------+ vtable_copy_visitor()) | |
| | add -------|------------------------>|add() |
| | sub -------|------------------------>|sub() |
| | | | |
| | | | |
| | | | |
+---+------------------+ +----------------------+
RPC
- Client:
- auto apic = std::make_shared<websocket_api_connection>(*con, MAX_DEPTH);
- auto remote_login_api = apic->get_remote_api<login_api>();
- auto remote_calc = remote_login_api->get_calc();
- Server:
- auto wsc = std::make_shared<websocket_api_connection>(*c, MAX_DEPTH);
- auto login = std::make_shared<login_api>();
- login->calc = calc_api;
- wsc->register_api(fc::api<login_api>(login));
![](https://img.haomeiwen.com/i5306326/ecb318bd6042899b.png)