Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef AESOP_SRV_MESSAGE_ROUTER_H__
00036 #define AESOP_SRV_MESSAGE_ROUTER_H__
00037
00038
00039 #include "aesop-proto/message.h"
00040 #include "story/story.h"
00041
00042
00043 namespace aesop {
00044
00046
00049 typedef netlib::conn_id_t conn_id_t;
00050 typedef netlib::envelope_t envelope_t;
00051 typedef netlib::MessageBuffer MessageBuffer;
00052
00053
00062 class StateUpdates {
00063 public:
00064
00065 virtual void newTcpConnectionTS(IN conn_id_t tcp_connId,
00066 IN long token) = 0;
00067 virtual void enqueueMessageTS(IN conn_id_t tcp_connId,
00068 IN smart_ptr<MessageBuffer>& msg) = 0;
00069 virtual void notifyDialogReplyTS(IN conn_id_t tcp_conn_id,
00070 IN const char * conversationGuid,
00071 IN int dialogId,
00072 IN int playerId,
00073 IN const Datahash * reply) = 0;
00074 virtual bool setPlayerUserAccountTS(IN conn_id_t tcp_conn_id,
00075 IN int playerId,
00076 IN const char * username,
00077 IN const char * usertag,
00078 OUT std::string& diagnostic) = 0;
00079 virtual void newGameTS(IN conn_id_t tcp_conn_id,
00080 IN int playerId) = 0;
00081 virtual void requestShutdownTS(void) = 0;
00082
00083 protected:
00085 virtual ~StateUpdates(void) throw();
00086 };
00087
00088
00090 struct handler_state_t {
00091
00092 handler_state_t(void) throw() { this->clear(); }
00093 void clear(void) throw() {
00094 src_env.clear();
00095 payload.clear();
00096 story = NULL;
00097 updates = NULL;
00098 }
00099
00100
00101 envelope_t src_env;
00102 tcp_payload_t payload;
00103 smart_ptr<story::Story> story;
00104 StateUpdates * updates;
00105 };
00106
00107
00109 typedef void (*msg_handler_fn)(IN handler_state_t& state);
00110
00111
00112
00116 class MessageRouter {
00117 public:
00118
00119 virtual ~MessageRouter(void) throw() = 0;
00120
00121
00122 virtual msg_handler_fn getHandler(IN const tcp_payload_t& payload) = 0;
00123
00124
00125 static smart_ptr<MessageRouter> create(void);
00126 };
00127
00128
00129
00130 };
00131
00132 #endif // AESOP_SRV_MESSAGE_ROUTER_H__
00133