Archived

This forum has been archived. Please start a new discussion on GitHub.

IceTouch and IceGrid

Dear all,

I want to connect a iOS App with a IceGrid Application, but first I have some problems with the connection. And second I can't found any other projects or sample for this use.

I changed the IceTouch and the objc Hello Example to connect to the IceGrid/Simple-Example, but with no success.

I hope anybody can me get the one significant hint.

I looking for your answers.

Thanks

Pencil

Comments

  • benoit
    benoit Rennes, France
    Hi,

    You can try it out by doing the following changes:
    • change the IceGrid simple demo to support the same Hello interface as the hello demo. For that, you need to add the "int delay" parameter to the sayHello method of the Hello interface defined in demo/IceGrid/simple/Hello.ice. You will also need to modify the HelloI.h and HelloI.cpp files to add this parameter to the servant implementation. Re-compile the demo and run IceGrid with the following command from the demo/Icegrid/simple directory:
        $ icegridnode --Ice.Config=config.grid --deploy application.xml
      
    • change the iPhone hello client to lookup for the hello object using IceGrid. For this, you can for example change the client createProxy method defined in /Developer/Examples/IceTouch-1.2.0/iPhone/hello/Classes/HelloController.m to the following:
      -(id<DemoHelloPrx>)createProxy
      {
          NSString* s;
      	int deliveryMode = [modePicker selectedRowInComponent:0];
      	if(deliveryMode == DeliveryModeTwowayAccessory || deliveryMode == DeliveryModeOnewayAccessory || deliveryMode == DeliveryModeOnewayAccessoryBatch)
      	{
      		s = @"hello:accessory -p com.zeroc.helloWorld";
      	}
      	else
      	{
      		s = @"hello"; // Use "hello" well-known proxy for the hello proxy.
      	}
      
      
          NSString* locatorS = [NSString stringWithFormat:@"DemoIceGrid/Locator:tcp -h %@ -p 4061",
                                hostnameTextField.text, hostnameTextField.text, hostnameTextField.text];
          
          [[NSUserDefaults standardUserDefaults] setObject:hostnameTextField.text forKey:hostnameKey];
      
          ICEObjectPrx* prx = [communicator stringToProxy:s];
          prx = [prx ice_locator:[ICELocatorPrx uncheckedCast:[communicator stringToProxy:locatorS]]];
          
          switch(deliveryMode)
          ...
      

      The code above specifies a locator proxy on the hello proxy. You could also define the Ice locator using the Ice.Default.Locator property.

    Cheers,
    Benoit.
  • Thanks, for the delay. Your post was the right solution.

    Now, I have a further question: I want to apply the singleton pattern for the proxy, but with objective-c I always get a EXC_BAD_ACCESS. After different tests, I think the ICECommunicator is the problem. Can you approve this behavior?
  • benoit
    benoit Rennes, France
    Hi,

    If nothing else retains the communicator object during the lifetime of your application, yes, it's quite possible this is the problem. We'll discuss whether or not the proxy should retain the communicator to prevent this.

    Cheers,
    Benoit.