I'm a bit confused about socket comms in LC, and am hoping somebody can clear it up for me.
Given the following
Code: Select all
on mouseUp
global strSocketConnection
if label of button "Connect" is "Connect" then
put strServerName & intLobbyPort into strSocketConnection
open socket to strSocketConnection --with message "connected"
write "*LOGIN::username::password" to socket strSocketConnection
set label of button "Connect" to "Disconnect"
read from socket theHost until crlf with message "readSomething"
else
close socket strSocketConnection
set label of button "Connect" to "Connect"
end if
end mouseUp
--currently not called for debugging
on connected theHost
--connected so login
write "*LOGIN::username::password" to socket theHost
set label of button "Connect" to "Disconnect"
read from socket theHost until crlf with message "readSomething"
end connected
on readSomething theHost theMessage
if theMessage is not empty then
put theMessage after field "ChatLog"
end if
read from socket theHost until crlf with message "readSomething"
end readSomething
In a previous incarnation I had this working, but accidentally deleted the button, and 'Undo' didn't, so am recreating from a less than stellar memory.
In the previous iteration I was able to get it into the 'readSomething' handler but it never called itself again which is what should happen given the 'read from...with message' command at the end, right?
I have no doubt this is something simple, but I'm still missing it.