質問

私は自分自身にデモこの分散オブジェクトを実行する方法を把握しようと頭痛を与えてくれました。私は、同じマシン上でローカルにうまくそれを実行することができます。

ここでは状況があります。私は[OpenGLView付き]リモートマシン上のスポーンクライアントアプリケーション、サーバアプリケーションを持っています。

私はAppleScriptでこれを簡単に行うことができます。

クライアントアプリケーションは、それのOpenGLViewウィンドウの[OK]をVENDているようです

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

サーバーアプリケーションがポートと接続見つかったが、タイムアウト例外を発生させます:

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

  }

そして、私は私WHYの生活のために把握することはできません。

私は、クライアントPCのコンソールで取得します: 「ポートOK」 「コネティカットOK」 "ポート8081:VEND OK"

私は、サーバーPCのコンソールで取得します: 「ポートOK」 「コネティカットOK」 11/18/09 2時05分36秒PM DOTest3 [15278] [NSPortCoder sendBeforeTime:sendReplyPort:(10280263936.092180 280263936.092642)タイムアウト1

タイムアウトが60秒に両方とも設定されている場合でもます。

ヘルプ!

-Stephen

<時間>

サーバー:MacMini OS X 10.5 クライアント:のMacPro OS X 10.6 などのリモートログイン、管理、すべて有効になっています。

<時間>

編集: NSResponderの提案を取って、私はコントローラを販売さてきましたが、それはまだ動作していません。

クライアント/ベンダーます:

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

クライアントコントローラーます:

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

サーバーコントローラーます:

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

サーバー/(オブジェクト販売さグラブ)

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

ため息...私、私はちょうどここに本当にココア-基本的な何かを見下ろすだと確信しています。

-S!

役に立ちましたか?

解決

私は、DOリンクを介してビューまたはウィンドウを、販売しようとする人を見たことがない、と私はそれがローカルホスト上でも働いたことに驚いています。いつでも私はDOを使用しました、それはクライアントの対応するコントローラへのサーバーのコントローラ層内のオブジェクトからなっています。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top