Home Help Center

IceTouch/Glacier2 Chat example: object adapter creation

jmsanchezjmsanchez Member Jose Manuel Sanchez Matamoros PerezOrganization: ZennioProject: home automation system remote controller
Hi,

I've been looking the chat example for IceTouch and I have a doubt about the object adapter creation. The code is the following one (in ChatController.m):
        id<ICEObjectAdapter> adapter = [communicator createObjectAdapterWithRouter:@"ChatDemo.Client" router:router];

        [adapter activate];

        ICEIdentity* callbackId = [ICEIdentity identity:[ICEUtil generateUUID] category:category];
        
        // Here we tie the chat view controller to the ChatRoomCallback servant.
        ChatChatRoomCallback* callbackImpl = [ChatChatRoomCallback objectWithDelegate:self];
        
        id<ICEObjectPrx> proxy = [adapter add:callbackImpl identity:callbackId];

In the first line you create the object adapter using the communicator and the Glacier2 router. I do not understand why you use the string "ChatDemo.Client" as argument. In a regular object adapter creation (without Glacier2), this argument would be the endpoint name, isn't it? Well, I've been looking for this endpoint in every Ice configuration file and didn't find.

Where has "ChatDemo.Client" been defined?

Thank you

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    The first argument of the createObjectAdapter method is the adapter name. This adapter name is also used as the property prefix to configure the object adapter -- it's not only to configure the endpoints of the adapter. See Ice Object Adapter Properties for a list of possible configuration properties for the object adapter.

    Cheers,
    Benoit.
  • jmsanchezjmsanchez Member Jose Manuel Sanchez Matamoros PerezOrganization: ZennioProject: home automation system remote controller
    In this case, How is ChatDemo.Client configured in the configuration file? (I cannot find it)

    I need to do something similar with an adapter with name "Test.Mobile". At this point, when I execute the following code:
    id<ICEObjectAdapter> adapter = [self.communicator createObjectAdapterWithRouter:@"Test.Mobile" router:router];
    

    I get an exception:
    Ice/ObjectAdapterI.cpp:915: Ice::InitializationException:
    initialization exception:
    object adapter `Test.Mobile' requires configuration
    
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    The object adapter creation either requires object adapter properties to be set (prefixed with the Test.Mobile prefix) or a router to be set.

    For the chat demo, no properties are specified but a non-nil router is provided.

    It looks like in your case the router proxy is also nil. Can you ensure that the router isn't nil by adding an NSAssert before the object adapter creation call?

    Cheers,
    Benoit.
  • jmsanchezjmsanchez Member Jose Manuel Sanchez Matamoros PerezOrganization: ZennioProject: home automation system remote controller
    You were right! router was equal to nil....

    Thank you very much for your help!
Sign In or Register to comment.