现在市面上这些 rpc 都太难用了。我做的 rpc 同样实现一个服务器:
// server.cpp
#include "lafrpc.h"
using namespace lafrpc;
class Hello: public QObject
{
Q_OBJECT
public slots:
QString sayHello(const QString &name) { return QStringLiteral("Hello, %1").arg(name); }
};
int main(int argc, char **argv)
{
auto rpc = RpcBuilder(MessagePack).create();
QSharedPointer<Hello> hello(new Hello());
rpc->registerInstance(hello, "demo");
rpc->startServer("tcp://127.0.0.1:8002", true);
return 0;
}
#include "server.moc"
【 在 lushan5436 (密如) 的大作中提到: 】
: 如果用thrift,没多少需要处理的。如果httpserver,libevent简单列子比下面的thrift代码还少
: #include<sys/socket.h>
: #include <thrift/concurrency/ThreadManager.h>
: ...................
--
修改:hgoldfish FROM 112.47.122.*
FROM 112.47.122.*