Domanda

Ho dato io stesso un mal di testa cercando di capire come far funzionare questo Distributed Objects demo. Posso farlo funzionare bene in locale sulla stessa macchina.

Ecco la situazione. Ho un app server che genera un client App [con OpenGLView] su una macchina remota.

che posso fare questo facile con AppleScript.

Il client App sembra Vend è OpenGLView finestra 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)]);
}

L'App Server trova il Porto e collegamento, ma solleva un'eccezione di timeout:

// 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];

  }

E io non riesco a capire per la vita di me perché.

ottengo nella console del PC client: "Port OK" "Conn OK" "Porto 8081: Vend OK"

ottengo nella console del PC server: "Port OK" "Conn OK" 11/18/09 14:05:36 DOTest3 [15278] [NSPortCoder sendBeforeTime: sendReplyPort:] timeout (10280263936,092,18 mila 280263936,092,642 mila) 1

Anche se i timeout sono entrambe impostate a 60 secondi.

Aiuto!

-Stephen


Server: MacMini OS X 10.5 Cliente: MacPro OS X 10.6 Accesso remoto, gestione, ecc sono tutti abilitati.


EDIT: Prendendo il suggerimento di NSResponder, ho vended il controller, ma ancora non sta funzionando.

Client / 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");
}

Regolatore 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;
}

Regolatore Server:

-(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];
}

Server / (palio vended Objects)

-(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 ... Sono sicuro che sto solo che si affaccia qualcosa di veramente cacao di base qui.

-S!

È stato utile?

Soluzione

Non ho mai visto nessuno di tentare di vend una vista o una finestra attraverso un collegamento DO, e sono sorpreso che ha funzionato anche sull'host locale. Ogni volta che ho usato DO, è stato da oggetti nello strato di controllo del server ad un corrispondente di controllo nel client.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top