سؤال

لقد أعطيت نفسي صداعًا أحاول معرفة كيفية تشغيل عرض الكائنات الموزعة هذا. يمكنني تشغيله بشكل جيد محليًا على نفس الجهاز.

هذا هو الوضع. لدي تطبيق خادم يولد تطبيق عميل [مع OpenGlview] على جهاز بعيد.

يمكنني القيام بذلك بسهولة مع Applescript.

يبدو أن تطبيق العميل يزيد من نافذة OpenGlview 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)]);
}

يجد تطبيق الخادم المنفذ والاتصال ، لكنه يثير استثناء مهلة:

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

  }

ولا يمكنني معرفة حياة لي لماذا.

أحصل على وحدة التحكم في جهاز الكمبيوتر العميل: "منفذ OK" "CONN OK" المنفذ 8081: Vend OK "

أحصل على وحدة التحكم في جهاز الكمبيوتر الخادم: "Port OK" "Conn OK" 11/18/09 2:05:36 PM DOTEST3 [15278] [NSPORTCODER SENDBEBEFORETIME: SENDREPLYPORT:] توقيت Out (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;
}

تنهد ... أنا متأكد من أنني فقط أطل على شيء من الكاكاو القاعدي هنا.

-س!

هل كانت مفيدة؟

المحلول

لم أر أبدًا أي شخص يحاول أن يزداد عرضًا أو نافذة عبر رابط Do ، وأنا مندهش من أنه عمل حتى على المضيف المحلي. في أي وقت اعتدت عليه ، كان من كائنات في طبقة وحدة التحكم للخادم إلى وحدة تحكم مقابلة في العميل.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top