首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

讯息机4

2013-09-10 
消息机4#include iostream#include AutoRelease.h#include MsgSvrItem.h#include MsgServer4.husi

消息机4

#include <iostream>#include "AutoRelease.h"#include "MsgSvrItem.h"#include "MsgServer4.h"using namespace std;class VoteTest:public IMsgListener, public AutoRelease{virtual bool OnEvt( char* _msg, void* _evt ){cout<<"VoteTest"<<endl;return false;}};class InitTest:public IMsgListener, public AutoRelease{virtual bool OnEvt( char* _msg, void* _evt ){cout<<"InitTest"<<endl;return false;}};class ActTest:public IMsgListener, public AutoRelease{virtual bool OnEvt( char* _msg, void* _evt ){cout<<"ActTest"<<endl;return false;}};class UninitTest:public IMsgListener, public AutoRelease{virtual bool OnEvt( char* _msg, void* _evt ){cout<<"UninitTest"<<endl;return false;}};void main(){MsgServer4 g_msg_svr4;IMsgServerItem* p_vote_svr = new VoteMsgSvrItem();IMsgServerItem* p_init_svr = new ActionMsgSvrItem();IMsgServerItem* p_action_svr = new ActionMsgSvrItem();IMsgServerItem* p_uninit_svr = new ActionMsgSvrItem();g_msg_svr4.PushSvr( MSG_SVR_TYPE::VOTE, p_vote_svr );g_msg_svr4.PushSvr( MSG_SVR_TYPE::INIT, p_init_svr );g_msg_svr4.PushSvr( MSG_SVR_TYPE::ACTION, p_action_svr );g_msg_svr4.PushSvr( MSG_SVR_TYPE::UNINIT, p_uninit_svr );VoteTest* p_vote = new VoteTest();InitTest* p_init = new InitTest();ActTest* p_act = new ActTest();UninitTest* p_uninit = new UninitTest();g_msg_svr4.AddListener("123", MSG_SVR_TYPE::VOTE, p_vote);g_msg_svr4.AddListener("123", MSG_SVR_TYPE::INIT, p_init);g_msg_svr4.AddListener("123", MSG_SVR_TYPE::ACTION, p_act);g_msg_svr4.AddListener("123", MSG_SVR_TYPE::UNINIT, p_uninit);g_msg_svr4.DispatchEvt("123", 0);system("pause");p_vote->Release();p_init->Release();p_act->Release();p_uninit->Release();}


热点排行