I'm trying to test-implement Distributed Object using the example server / client from the book "Cocoa Programming" by Scott Anguish, Erik M. Buck, Donald A. Yacktman (chapter 23). <http://www.cocoaprogramming.net/Downloads.html>
I've kept the sample server in Objective C, and I'm trying to implement the client in PyFit. What I'm stuck on right now is a crash calling self.server.addMessageClient_( self ) in my method applicationDidFinishLaunching_ Do you have any suggestions? I can send the crash-log as well... Here's the python source code: ************************************ # # DOTestPythonClientAppDelegate.py # DOTestPythonClient # from Foundation import * from AppKit import * from PyObjCTools import * from objc import * MYMessageServerProtocol = formal_protocol( u'MYMessageServerProtocol', None, [ selector( None, selector='addMessageClient:', signature='[EMAIL PROTECTED]:[EMAIL PROTECTED]'), selector( None, selector='removeMessageClient:', signature='[EMAIL PROTECTED]:[EMAIL PROTECTED]'), selector( None, selector='broadcastMessageString:', signature='[EMAIL PROTECTED]:[EMAIL PROTECTED]') ] ) class DOTestPythonClientAppDelegate(NibClassBuilder.AutoBaseClass): composeView = ivar(u'composeView') messageView = ivar(u'messageView') sendButton = ivar(u'sendButton') server = None def sendMessage_(self,aSender): NSLog( u"sendMessage_ ." ) self.server.broadcastMessageString_( self.composeView.string() ) self.composeView.setString_( u'' ) def appendMessageString_(self,aSstring): # called by server... NSLog( u"appendMessageString ." ) #NSRange appendRange = NSMakeRange( self.messageView.string().length(), 0); #Append text and scroll if neccessary self.messageView.replaceCharactersInRange_withString_( appendRange, aString ); self.messageView.scrollRangeToVisible_( appendRange ) return self def connectionDidDie_(self,aNotification): NSLog( u"Error: Connection to server is broken." ) def applicationDidFinishLaunching_(self,aNotification): NSLog( u"applicationDidFinishLaunching_ ." ) self.server = NSConnection.rootProxyForConnectionWithRegisteredName_host_( u"server", None ).retain() if None == self.server : NSLog( u"Error: Failed to connect to server." ) else: NSLog( u"did connect to server." ) connectionDidDie_SEL = selector( self.connectionDidDie_, selector='connectionDidDie:', signature="[EMAIL PROTECTED]:[EMAIL PROTECTED]" ) NSNotificationCenter.defaultCenter().addObserver_selector_name_object_( self, connectionDidDie_SEL, NSConnectionDidDieNotification, None ) NSLog( u"called defaultCenter().addObserver_selector_name_object_." ) self.server.setProtocolForProxy_( MYMessageServerProtocol ) NSLog( u"called self.server.setProtocolForProxy_." ) self.server.addMessageClient_( self ) # crashing here... NSLog( u"called self.server.addMessageClient_." ) astr = u"Connected: %s %d" % NSProcessInfo.processInfo().processName(), NSProcessInfo.processInfo().processIdentifier() NSLog( u"astr = '%s'" % astr ) self.server.broadcastMessageString_( astr ) # convert to NSString NSLog( u"called self.server.broadcastMessageString_." ) def applicationWillTerminate_(self,aNotification): NSLog( u"applicationWillTerminate_ ." ) if NO == self.server.removeMessageClient_(self) : NSLog( u"Error: Failed to remove client." ) self.server.release() self.server = None -- C. Keith Ray <http://homepage.mac.com/keithray/blog/index.html> <http://homepage.mac.com/keithray/xpminifaq.html> <http://homepage.mac.com/keithray/resume2.html> _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig