diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-07-14 16:46:54 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-07-14 16:46:54 +0000 |
commit | e4f132a981fabf0bb70ac61a12a7d33902f5a0ac (patch) | |
tree | d9e9400a722f9a784ec7fe2f0c545870e2f95adb /cppe/demo/IceE/minimal/Server.cpp | |
parent | Added retrieval of login info from user. (diff) | |
download | ice-e4f132a981fabf0bb70ac61a12a7d33902f5a0ac.tar.bz2 ice-e4f132a981fabf0bb70ac61a12a7d33902f5a0ac.tar.xz ice-e4f132a981fabf0bb70ac61a12a7d33902f5a0ac.zip |
It is not possible to compile the client side library with router support.
Diffstat (limited to 'cppe/demo/IceE/minimal/Server.cpp')
-rw-r--r-- | cppe/demo/IceE/minimal/Server.cpp | 225 |
1 files changed, 3 insertions, 222 deletions
diff --git a/cppe/demo/IceE/minimal/Server.cpp b/cppe/demo/IceE/minimal/Server.cpp index 01e6c8ecc5d..1d336d26c5c 100644 --- a/cppe/demo/IceE/minimal/Server.cpp +++ b/cppe/demo/IceE/minimal/Server.cpp @@ -11,8 +11,9 @@ #include <Hello.h> using namespace std; +using namespace Demo; -class HelloI : public ::Demo::Hello +class HelloI : public Hello { public: @@ -30,230 +31,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Ice::ObjectPtr object = new HelloI; adapter->add(object, Ice::stringToIdentity("hello")); adapter->activate(); -#ifndef _WIN32_WCE communicator->waitForShutdown(); -#endif - return EXIT_SUCCESS; -} - -#ifdef _WIN32_WCE - -#define IDC_MAIN_EDIT 101 - -static HWND hEdit; -static HWND mainWnd; -static IceUtil::ThreadControl mainThread; - -void -tprintf(const char* fmt, ...) -{
- va_list va; - va_start(va, fmt); - char buf[1024]; - _vsnprintf(buf, sizeof(buf)-1, fmt, va); - buf[sizeof(buf)-1] = '\0'; - va_end(va);
-
- char* start = buf; - const char* end = start + strlen(start); - char* curr = start; - while(curr < end) - { - bool nl = false; - while(curr < end && *curr != '\n') - { - // Not designed to handle \r - assert(*curr != '\r'); - ++curr; - } - if(*curr == '\n') - { - nl = true; - } - *curr = '\0'; - static TCHAR nlStr[] = L"\r\n"; -
- //
- // If the thread is not the main thread we have to post a message
- // to the main thread to do the EM_REPLACESEL. Calling SendMessage
- // from a thread other than main is not permitted.
- // - if(IceUtil::ThreadControl() != mainThread) - { - wchar_t* wtext = new wchar_t[sizeof(wchar_t) * (curr - start)+1]; - mbstowcs(wtext, start, (curr - start) + 1); - ::PostMessage(mainWnd, WM_USER, (WPARAM)FALSE, (LPARAM)wtext); - if(nl) - { - wchar_t* wtext = new wchar_t[sizeof(nlStr)]; - wcscpy(wtext, nlStr); - ::PostMessage(mainWnd, WM_USER, (WPARAM)FALSE, (LPARAM)wtext); - } - } - else - { - TCHAR wtext[1024]; - mbstowcs(wtext, start, (curr - start) + 1); - ::SendMessage(hEdit, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)wtext); - if(nl) - { - ::SendMessage(hEdit, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)nlStr); - } - } - ++curr; - start = curr; - } - - // - // Process pending events. - // - if(IceUtil::ThreadControl() == mainThread) - { - MSG Msg; - while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&Msg); - DispatchMessage(&Msg); - } - } -} - -static LRESULT CALLBACK -WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_USER: - { - // tprint from a thread other than main. lParam holds a pointer to the text. - ::SendMessage(hEdit, EM_REPLACESEL, (WPARAM)wParam, (LPARAM)lParam); - wchar_t* text = (wchar_t*)lParam; - delete[] text; - } - break; - - case WM_CREATE: - { - //HFONT hfDefault; - - RECT rcClient; - GetClientRect(hWnd, &rcClient); - hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"", - WS_CHILD | WS_VISIBLE | WS_VSCROLL /*| WS_HSCROLL*/ | ES_MULTILINE, - 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, - /*0,0,100,100,*/ - hWnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL); - assert(hEdit != NULL); - } - break; - - case WM_SIZE: - { - HWND hEdit; - RECT rcClient; - - GetClientRect(hWnd, &rcClient); - - hEdit = GetDlgItem(hWnd, IDC_MAIN_EDIT); - SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER); - } - break; - - case WM_CLOSE: - DestroyWindow(hWnd); - break; - - case WM_DESTROY: - PostQuitMessage(0); - break; - - default: - return DefWindowProc(hWnd, msg, wParam, lParam); - } - return 0; -} -int WINAPI -WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) -{ - static const TCHAR windowClassName[] = L"Minimal Server"; - WNDCLASS wc; - - wc.style = CS_HREDRAW|CS_VREDRAW; - wc.lpfnWndProc = (WNDPROC)WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, 0/*IDI_APPLICATION*/); - wc.hCursor = 0; - wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); - wc.lpszMenuName = NULL; - wc.lpszClassName = windowClassName; - - if(!RegisterClass(&wc)) - { - MessageBox(NULL, L"Window Registration Failed!", L"Error!", - MB_ICONEXCLAMATION | MB_OK); - return 0; - } -
- mainWnd = CreateWindow(windowClassName, L"Minimal Server", WS_VISIBLE|WS_OVERLAPPED|WS_SYSMENU|WS_SIZEBOX, - CW_USEDEFAULT, CW_USEDEFAULT, 320, 200, - NULL, NULL, hInstance, NULL); - if(mainWnd == NULL) - { - MessageBox(NULL, L"Window Creation Failed!", L"Error!", - MB_ICONEXCLAMATION | MB_OK); - return 0; - } - - ShowWindow(mainWnd, SW_SHOW); - UpdateWindow(mainWnd); - int status = EXIT_SUCCESS; - - extern int __argc; - extern char **__argv; - - Ice::CommunicatorPtr communicator; - - try - { - Ice::PropertiesPtr properties = Ice::createProperties(); - properties->setProperty("Hello.Endpoints","tcp -p 10000"); - communicator = Ice::initializeWithProperties(__argc, __argv, properties); - status = run(__argc, __argv, communicator); - } - catch(const Ice::Exception& ex) - { - tprintf("%s\n", ex.toString().c_str()); - status = EXIT_FAILURE; - } - tprintf("Close the window to terminate the server.\n"); - - MSG Msg; - while(GetMessage(&Msg, NULL, 0, 0) > 0) - { - TranslateMessage(&Msg); - DispatchMessage(&Msg); - } - - if(communicator) - { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - tprintf("%s\n", ex.toString().c_str()); - status = EXIT_FAILURE; - } - } - return status; + return EXIT_SUCCESS; } -#else - int main(int argc, char* argv[]) { @@ -288,4 +70,3 @@ main(int argc, char* argv[]) return status; } -#endif |