Multithreading Dilemma
Multithreading Dilemma
- Subject: Multithreading Dilemma
- From: "Jean-Olivier Lanctôt-D." <email@hidden>
- Date: Fri, 16 May 2003 23:57:43 -0400
Hi list,
You guys are like my last resort, I tried EVERYTHING today :)
Here's the situation:
I have two majors objects in my game: a WarController which handles
communication with all the game's view: e.g. the board, the score view,
etc and a CommController which handles communication with the remote
player (multiplayer). I use my customized version of SmallSockets ( I
implemented timeouts and other stuff ) with **threads** to communicate.
Suppose I want to host a game, I send - listenInBackground to the
CommController. it sets up a socket, and then spawns a thread which
will WAIT (block) till someone connects. Then it will read data until
an exception is raised. Each time it gets new data, it passes back the
data to a "parsing" function inside CommController too.
That same parsing method first parses the important info out of the
packet AND THEN reacts to that data. Suppose the remote player sent a
packet saying that he's moved from E3 to D2 or whatever (it's not
important). Well that method needs to _*communicate*_ with
WarController (**NOT IN THE SAME THREAD**). It sends a setState:
message to WarController which in turns updates the UI accordingly
(**calling appkit objects**)... The problem is that the appkit objects
don't react to those methods.
I tried performSelectorInMainThread, NSConnections (as seen in
SAnguish's Cocoa Book), pretty much everything I can think of...
still.. doesn't work.
Help!
Thanks in advance!
--Jean-Olivier Lancttt-David
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.