10 #ifndef INCLUDE_FUNAPI_DISTRIBUTION_DEDICATED_SERVER_RPC_H_ 11 #define INCLUDE_FUNAPI_DISTRIBUTION_DEDICATED_SERVER_RPC_H_ 13 #include <boost/asio.hpp> 14 #include <boost/function.hpp> 15 #include <boost/noncopyable.hpp> 16 #include <funapi/distribution/fun_dedicated_server_rpc_message.pb.h> 28 typedef boost::asio::ip::tcp::endpoint PeerEndpoint;
29 typedef std::map<PeerId, PeerEndpoint> PeerMap;
39 typedef boost::function<
40 void(
const PeerId &,
const Xid &,
41 const Ptr<const FunDedicatedServerRpcMessage> &)>
Callback;
43 static const Xid kNullXid;
44 static const PeerId kNullPeerId;
49 static bool HasTag(
const PeerId &peer,
const Tag &tag);
54 static Tag GetPeerTag(
const PeerId &peer);
59 static size_t GetPeers(PeerMap *ret);
65 static size_t GetPeersWithTag(PeerMap *ret,
const Tag &tag);
70 static bool IsPeerConnected(
const PeerId &peer);
73 static void RegisterConnectHandler(
const ConnectHandler &h);
76 static void RegisterDisconnectHandler(
const DisconnectHandler &h);
82 static void Call(
const PeerId &peer,
83 const Ptr<FunDedicatedServerRpcMessage> &msg,
84 const Callback &callback) ASSERT_NO_ROLLBACK;
89 static void CallRandomly(
const Ptr<FunDedicatedServerRpcMessage> &msg,
90 const Callback &callback) ASSERT_NO_ROLLBACK;
95 #endif // INCLUDE_FUNAPI_DISTRIBUTION_DEDICATED_SERVER_RPC_H_
Definition: dedicated_server_rpc.h:24
boost::function< void(const PeerId &)> ConnectHandler
Functor to be invoked when a peer connected.
Definition: dedicated_server_rpc.h:33
boost::uuids::uuid Uuid
UUID type used throughout Funapi.
Definition: types.h:56
boost::function< void(const PeerId &)> DisconnectHandler
Functor to be invoked when a peer disconnected.
Definition: dedicated_server_rpc.h:36
boost::function< void(const PeerId &, const Xid &, const Ptr< const FunDedicatedServerRpcMessage > &)> Callback
Functor to be invoked when a client receives back a reply.
Definition: dedicated_server_rpc.h:41