iFun Engine API  1.0.0-b2601
Great Technology for Great Games
 All Classes Files Functions Variables Typedefs Macros
multicast_server.h
Go to the documentation of this file.
1 // Copyright (C) 2017 iFunFactory Inc. All Rights Reserved.
2 //
3 // This work is confidential and proprietary to iFunFactory Inc. and
4 // must not be used, disclosed, copied, or distributed without the prior
5 // consent of iFunFactory Inc.
6 
9 #ifndef INCLUDE_FUNAPI_SERVICE_MULTICAST_SERVER_H_
10 #define INCLUDE_FUNAPI_SERVICE_MULTICAST_SERVER_H_
11 
12 #include <boost/unordered_map.hpp>
13 #include <funapi/common/json.h>
14 #include <funapi/types.h>
15 
16 
17 namespace fun {
18 
19 typedef Uuid SessionId;
20 class Session;
21 
22 
24  public:
25  typedef function<
26  bool(const string & /*channel*/,
27  const string & /*sender*/,
28  const Ptr<Session> & /*session*/,
29  Json * /*message*/)> JsonMessageChecker;
30  typedef function<
31  bool(const string & /*channel*/,
32  const string & /*sender*/,
33  const Ptr<Session> & /*session*/,
34  const Ptr<FunMessage> & /*message*/)> ProtobufMessageChecker;
35 
36  typedef function<
37  void(const string & /*channel*/,
38  const string & /*sender*/,
39  const SessionId & /*session_id*/,
40  const Json & /*message*/)> JsonMessageHook;
41  typedef function<
42  void(const string & /*channel*/,
43  const string & /*sender*/,
44  const SessionId & /*session_id*/,
45  const Ptr<const FunMessage> & /*message*/)> ProtobufMessageHook;
46 
47  static void InstallJsonMessageChecker(
48  const JsonMessageChecker &json_message_checker);
49 
50  static void InstallProtobufMessageChecker(
51  const ProtobufMessageChecker &protobuf_message_checker);
52 
53  static void InstallJsonMessageHook(const JsonMessageHook &hook);
54 
55  static void InstallProtobufMessageHook(const ProtobufMessageHook &hook);
56 };
57 
58 
59 typedef boost::unordered_map<string /*channel*/,
60  string /*token*/> MulticastChannelTokenMap;
61 
62 // Creates a server-side multicast channel.
63 // This function must be called on both the game server and the multicast server.
64 void CreateMulticastChannel(const string &channel, const string &token);
65 
66 // Gets a server-side multicast channel.
67 bool GetMulticastChannel(const string &channel, string *out_token);
68 
69 // Gets the server-side multicast channels.
70 size_t GetMulticastChannelTokenMap(MulticastChannelTokenMap *out);
71 
72 // Disallows to create a client-side multicast channel.
73 void DisallowToCreateClientsideMulticastChannel();
74 
75 } // namespace fun
76 
77 #endif // INCLUDE_FUNAPI_SERVICE_MULTICAST_SERVER_H_
Definition: json.h:27
Definition: multicast_server.h:23