@@ -86,19 +86,21 @@ id target; SEL selector; #ifdef OF_HAVE_BLOCKS of_tcpsocket_async_connect_block_t connectBlock; #endif + id context; OFException *exception; } - initWithSourceThread: (OFThread*)sourceThread socket: (OFTCPSocket*)socket host: (OFString*)host port: (uint16_t)port target: (id)target - selector: (SEL)selector; + selector: (SEL)selector + context: (id)context; #ifdef OF_HAVE_BLOCKS - initWithSourceThread: (OFThread*)sourceThread socket: (OFTCPSocket*)socket host: (OFString*)host port: (uint16_t)port @@ -111,10 +113,11 @@ socket: (OFTCPSocket*)sock_ host: (OFString*)host_ port: (uint16_t)port_ target: (id)target_ selector: (SEL)selector_ + context: (id)context_ { self = [super init]; @try { sourceThread = [sourceThread_ retain]; @@ -121,10 +124,11 @@ sock = [sock_ retain]; host = [host_ copy]; port = port_; target = [target_ retain]; selector = selector_; + context = [context_ retain]; } @catch (id e) { [self release]; @throw e; } @@ -162,10 +166,11 @@ [host release]; [target release]; #ifdef OF_HAVE_BLOCKS [connectBlock release]; #endif + [context release]; [exception release]; [super dealloc]; } @@ -176,15 +181,15 @@ #ifdef OF_HAVE_BLOCKS if (connectBlock != NULL) connectBlock(sock, exception); else { #endif - void (*func)(id, SEL, OFTCPSocket*, OFException*) = - (void(*)(id, SEL, OFTCPSocket*, OFException*))[target + void (*func)(id, SEL, OFTCPSocket*, id, OFException*) = + (void(*)(id, SEL, OFTCPSocket*, id, OFException*))[target methodForSelector: selector]; - func(target, selector, sock, exception); + func(target, selector, sock, context, exception); #ifdef OF_HAVE_BLOCKS } #endif } @@ -424,20 +429,22 @@ - (void)asyncConnectToHost: (OFString*)host port: (uint16_t)port target: (id)target selector: (SEL)selector + context: (id)context { void *pool = objc_autoreleasePoolPush(); [[[[OFTCPSocket_ConnectThread alloc] initWithSourceThread: [OFThread currentThread] socket: self host: host port: port target: target - selector: selector] autorelease] start]; + selector: selector + context: context] autorelease] start]; objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_BLOCKS @@ -649,14 +656,16 @@ return newSocket; } - (void)asyncAcceptWithTarget: (id)target selector: (SEL)selector + context: (id)context { [OFRunLoop OF_addAsyncAcceptForTCPSocket: self target: target - selector: selector]; + selector: selector + context: context]; } #ifdef OF_HAVE_BLOCKS - (void)asyncAcceptWithBlock: (of_tcpsocket_async_accept_block_t)block {