Pregunta

Yo mismo he dado un dolor de cabeza tratando de encontrar la manera de ejecutar esta demostración objetos distribuidos. Puedo correr, estuvo bien localmente en la misma máquina.

Esta es la situación. Tengo un servidor de aplicaciones que genera un cliente App [con OpenGLView] en una máquina remota.

Puedo hacer esto fácil con AppleScript.

La aplicación de cliente parece Vend es OpenGLView ventana OK:

clientPort = [[NSSocketPort alloc] initWithTCPPort:SERVER_PORT];
if(clientPort == nil) continue; else NSLog(@"Port OK");

clientConnection = [NSConnection connectionWithReceivePort:clientPort sendPort:nil];
if(clientConnection == nil) continue; else NSLog(@"Conn OK");

[[NSSocketPortNameServer sharedInstance] registerPort:clientPort name:@"DOTest3_0"];

//Vend Object
@try {
[clientConnection setRootObject:object];
NSLog([NSString stringWithFormat:@"Port %d: Vend OK", (SERVER_PORT + i)]);
return;
} @catch (...) {
NSLog([NSString stringWithFormat:@"Port %d: Vend Next", (SERVER_PORT + i)]);
}

El servidor de aplicaciones se encuentra el puerto y la conexión, pero plantea una excepción de tiempo de espera:

// Create temporary Pointer to kGLView Object.
  id <NSCoding, kGLViewProtocol> openGLView;

      // Setup Port, Connection, & Proxy
      portTest = (NSSocketPort *)[[NSSocketPortNameServer sharedInstance] portForName:@"DOTest3_0" host:@"*"];
      if (portTest == nil ) continue ; else NSLog(@"Port OK");

      connTest = [NSConnection  connectionWithReceivePort:nil sendPort:portTest];
      if (connTest == nil ) continue ; else NSLog(@"Conn OK");

      openGLView = [[connTest rootProxy] retain];
      if (openGLView == nil ) continue ; else NSLog(@"OpenGL OK");

      [openGLView drawWithRotation: rotationAngle];

  }

Y no puedo averiguar por la vida de mí por qué.

Me meto en la Consola del PC Cliente: "Puerto OK" "Conn OK" "Puerto 8081: Vend OK"

Me meto en la consola del servidor de PC: "Puerto OK" "Conn OK" 11/18/09 02:05:36 PM DOTest3 [15278] [NSPortCoder sendBeforeTime: sendReplyPort:] tiempo de espera agotado (10280263936.092180 280263936,092642) 1

Aunque los TimeOuts están establecidos en 60 segundos.

Ayuda!

-Stephen


Servidor: MacMini OS X 10.5 Cliente: MacPro OS X 10.6 Inicio de sesión remoto, administración, etc, todos ellos habilitado.


EDIT: Tomando la sugerencia de NSResponder, he expendido el controlador, pero todavía no está funcionando.

Cliente / Vender:

-(void)vend:(id)object {
  port = [[[NSSocketPort alloc] initWithTCPPort:[self tcpPort]] 
          retain];

  conn = [[NSConnection connectionWithReceivePort:port sendPort:nil] 
          retain];

  for (int i = 0; i < 10; i++) {
    [[NSSocketPortNameServer sharedInstance] registerPort:port
                                                     name:[[self portName] stringByAppendingFormat:@"_%d", i]];
    @try {
      [conn setRootObject:object];
      return;
    } @catch (...) {
      NSLog(@"Vend Next");
      continue;
    }
  }
  NSLog(@"Vend Failed");
}

Controlador Cliente:

-(id)init {
  self = [super init];

  [self setRotationAngle:0.0f];

  clientObj = [[Client alloc] initWithName:@"DOTest4" 
                                   Address:@"10.10.5.104" // mini
                                      Port:48557];

  [clientObj vend:self];

  return self;
}

Controlador Servidor:

-(IBAction)rotateClient:(id)sender {
  NSArray *vendedObjects = [serverObj getVendedObjects];
  id <NSCoding, ClientController_Protocol> proxy;

  if (vendedObjects != nil) {
    for (int i = 0; i < [vendedObjects count]; i++) {
      proxy = [vendedObjects objectAtIndex:i];
      [proxy rotate];
    }
  }
    // release
  [vendedObjects release];
}

Servidor / (juego de máquinas expendedoras Objetos)

-(NSArray *)getVendedObjects {

  NSArray *vendedObjects = [[[NSArray alloc] init] retain];
  NSSocketPort *port;
  NSConnection *conn;

  for (int i = 0; i< 10; i++) {
    // Get Port Object
    port = (NSSocketPort *)[[NSSocketPortNameServer sharedInstance] 
                           portForName:[[self portName] stringByAppendingFormat:@"_%d", i]
                           host:[self addressRemote]];
    if (port == nil) continue;
    // Create Connection with Timeouts
    conn = [NSConnection connectionWithReceivePort:nil sendPort:port];
    if (conn == nil) continue;

    [conn setReplyTimeout:(NSTimeInterval)60.0];
    [conn setRequestTimeout:(NSTimeInterval)60.0];

    // Get VendedObject of Connection
    vendedObjects = [[vendedObjects arrayByAddingObject:[conn rootProxy]] retain];
  }

  return vendedObjects;
}

Sigh ... Estoy seguro de que simplemente estoy pasando por alto algo realmente cacao básica aquí.

S

¿Fue útil?

Solución

Nunca he visto a cualquiera que trate de expender una vista o una ventana a través de un enlace de DO, y me sorprende que haya funcionado, incluso en el host local. Cada vez que he usado DO, ha sido de los objetos en la capa del controlador del servidor a un controlador correspondiente en el cliente.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top