1// 2// Copyright (c) ZeroC, Inc. All rights reserved. 3// 4 5#import <objc/Ice.h> 6#import <hold/TestI.h> 7#import <TestCommon.h> 8 9static int 10run(id<ICECommunicator> communicator) 11{ 12 [[communicator getProperties] setProperty:@"TestAdapter1.Endpoints" value:@"default -p 12010 -t 10000:udp"]; 13 [[communicator getProperties] setProperty:@"TestAdapter1.ThreadPool.Size" value:@"5"]; 14 [[communicator getProperties] setProperty:@"TestAdapter1.ThreadPool.SizeMax" value:@"5"]; 15 [[communicator getProperties] setProperty:@"TestAdapter1.ThreadPool.SizeWarn" value:@"0"]; 16 [[communicator getProperties] setProperty:@"TestAdapter1.ThreadPool.Serialize" value:@"0"]; 17 id<ICEObjectAdapter> adapter1 = [communicator createObjectAdapter:@"TestAdapter1"]; 18 19 [[communicator getProperties] setProperty:@"TestAdapter2.Endpoints" value:@"default -p 12011 -t 10000:udp"]; 20 [[communicator getProperties] setProperty:@"TestAdapter2.ThreadPool.Size" value:@"5"]; 21 [[communicator getProperties] setProperty:@"TestAdapter2.ThreadPool.SizeMax" value:@"5"]; 22 [[communicator getProperties] setProperty:@"TestAdapter2.ThreadPool.SizeWarn" value:@"0"]; 23 [[communicator getProperties] setProperty:@"TestAdapter2.ThreadPool.Serialize" value:@"1"]; 24 id<ICEObjectAdapter> adapter2 = [communicator createObjectAdapter:@"TestAdapter2"]; 25 26 [adapter1 add:[HoldI hold] identity:[ICEUtil stringToIdentity:@"hold"]]; 27 [adapter2 add:[HoldI hold] identity:[ICEUtil stringToIdentity:@"hold"]]; 28 29 [adapter1 activate]; 30 [adapter2 activate]; 31 32 serverReady(communicator); 33 34 [communicator waitForShutdown]; 35 36 return EXIT_SUCCESS; 37} 38 39#if TARGET_OS_IPHONE 40# define main holdServer 41#endif 42 43int 44main(int argc, char* argv[]) 45{ 46#ifdef ICE_STATIC_LIBS 47 ICEregisterIceSSL(YES); 48 ICEregisterIceWS(YES); 49 ICEregisterIceUDP(YES); 50#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR 51 ICEregisterIceIAP(YES); 52#endif 53#endif 54 55 @autoreleasepool 56 { 57 int status; 58 id<ICECommunicator> communicator = nil; 59 60 @try 61 { 62 ICEInitializationData* initData = [ICEInitializationData initializationData]; 63 initData.properties = defaultServerProperties(&argc, argv); 64#if TARGET_OS_IPHONE 65 initData.prefixTable_ = [NSDictionary dictionaryWithObjectsAndKeys: 66 @"TestHold", @"::Test", 67 nil]; 68#endif 69 70 communicator = [ICEUtil createCommunicator:&argc argv:argv initData:initData]; 71 status = run(communicator); 72 } 73 @catch(ICEException* ex) 74 { 75 tprintf("%@\n", ex); 76 status = EXIT_FAILURE; 77 } 78 79 if(communicator) 80 { 81 [communicator destroy]; 82 } 83 return status; 84 } 85} 86