00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "implem_only.h"
00016 #include "t_rpc_server.h"
00017
00018 #include <mfc_ext/debugging_console_window.h>
00019 #include <mfc_ext/debugging_frame.h>
00020 #include <opsystem/path_configuration.h>
00021 #include <data_struct/static_memory_gremlin.h>
00022
00023 HOOPLE_STARTUP_CODE;
00024
00026
00028
00029 BEGIN_MESSAGE_MAP(test_rpc_server, CFrameWnd)
00030
00031 ON_WM_CREATE()
00032 ON_WM_CLOSE()
00033
00034 ON_COMMAND(CM_FILE_OPEN_SERV, open_rpc)
00035 ON_COMMAND(CM_FILE_CLOSE_SERV, close_rpc)
00036 ON_COMMAND(CM_FILE_QUIT_SERV, exit_program)
00037 END_MESSAGE_MAP()
00038
00040
00041 test_rpc_server::test_rpc_server()
00042 : CFrameWnd(),
00043 #ifdef DEBUG_RPC
00044 console(new debugging_frame()),
00045 #endif
00046 my_server(NIL)
00047 {}
00048
00049 test_rpc_server::~test_rpc_server() {}
00050
00051 int test_rpc_server::OnCreate(LPCREATESTRUCT lpCreateStruct)
00052 {
00053 if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1;
00054 #ifdef DEBUG_RPC
00055 console->console().name(path_configuration::make_logfile_name("t_rpcser.log"));
00056 console->Create(NIL, "RPC Server Bug Console");
00057 console->show();
00058 #endif
00059 the_menu.LoadMenu(SERVER_MENU);
00060 SetMenu(&the_menu);
00061
00062 HICON icon = LoadIcon(AfxGetInstanceHandle(),
00063 MAKEINTRESOURCE(RPC_tester_icon));
00064 SetIcon(icon, true);
00065 SetIcon(icon, false);
00066 return 0;
00067 }
00068
00069 void test_rpc_server::OnClose()
00070 {
00071 close_rpc();
00072 CFrameWnd::OnClose();
00073 }
00074
00075 void test_rpc_server::open_rpc()
00076 {
00077 if (my_server) {
00078 #ifdef DEBUG_RPC
00079 console->console().print("the rpc server is already open.");
00080 #endif
00081 return;
00082 }
00083 window_handle recip = NIL;
00084 #ifdef DEBUG_RPC
00085 recip = console->GetSafeHwnd();
00086 #endif
00087 my_server = new example_rpc_server(this, recip);
00088 }
00089
00090 void test_rpc_server::close_rpc()
00091 {
00092 if (my_server) {
00093 #ifdef DEBUG_RPC
00094 console->console().print("deleting my server.");
00095 #endif
00096 delete my_server;
00097 my_server = NIL;
00098 }
00099 }
00100
00101 void test_rpc_server::exit_program() { PostMessage(WM_CLOSE); }
00102
00104
00105 class rpc_server_test_application : public CWinApp
00106 {
00107 public:
00108 rpc_server_test_application() : CWinApp() {}
00109 virtual BOOL InitInstance();
00110 };
00111
00112 BOOL rpc_server_test_application::InitInstance()
00113 {
00114 test_rpc_server *new_main = new test_rpc_server();
00115 ASSERT_VALID(new_main);
00116 if (new_main) {
00117 new_main->Create(NIL, "rpc server test");
00118
00119
00120 m_pMainWnd = new_main;
00121
00122
00123 m_pMainWnd->ShowWindow(m_nCmdShow);
00124 }
00125 return true;
00126 }
00127
00128 rpc_server_test_application theApp;
00129