[Newbies] Re: Building a remote countdown clock
herbertkoenig at gmx.net
Sat Nov 7 10:25:02 UTC 2009
AB> That's great, thank you very much. I have a couple of other
AB> questions that sprang from using this code.
AB> 1. I couldn't get the WorldState addDeferredUIMessage: to do
AB> anything. What is supposed to happen? I am running the latest
AB> Pharo build. The class exists, and I didn't get a DNU, but I
AB> didn't get anything else either!
uh yeah I wasn't sure what approach you would choose and I was about
to leave for work. Sorry.
First I'm on Squeak 3.8 so let me try Pharo.
All works fine in what I just downloaded from Pharo Website.
So, after you added the deferred UI message, the next line
(sendUDPData...) should pop up an Inspector with an Array. I found the
deferred UI message trick somewhere in the archives or maybe got
direct help from someone. You won't need it.
You need two images. In the receiver you build a loop in which you do
ifTrue: [receiveResult :=
commSocket receiveUDPDataInto: receiveBuffer.
"now display your time in a big TextMorph"]
ifFalse: [myDelay wait]
Doing real time asynchronous things with the Squeak UI is a bit tricky
but following the lead of ClockMorph should get you going.
The common animation methods in Squeak isolate you from that problems
but changing a Morph's shape at the wrong moment is not good. Sorry I
can't be more specific but if you report problems I will remember
them, I did several animations of lots of Morphs.
AB> 2. Out of curiosity, I tried used the NetNameResolver
AB> addressForName: method as a way of getting a socket address
AB> (instead of using the ByteArray. I tried this when nothing was
AB> working, and I noticed the method call in several of the Socket
AB> methods. However, Squeak gave me a DNU. Is there a simple way to
AB> enter host names using the NetNameResolver, or have I completely
AB> misunderstood its function?
no, you haven't. I used the code in a network with fixed IP's and no
DHCP running. Right here using NetNameResolver works just fine. If you
(NetNameResolver addressForName: 'aComputersName') inspect
you should get an Inspector on a ByteArray with the IP address.
More information about the Beginners