NetCompanionSet xtras for Macromedia DirectorAsynchronous client component of SocketServerXtra
You may use native multiuser xtra shipped with Shockwave player or Director 8.5. Shockwave xtras are normally installed here:
C:\WINDOWS\system32\Macromed\Shockwave 10\Xtras
Using multiuser xtra requires parent script object (with name "NetHandler") that will handle incoming messages. It may look like this:
global oConnection
-- StandartHandler
on defaultCallback me
msg = oConnection.getNetMessage()
if msg[#ErrorCode] then
put oConnection.GetNetErrorString( msg[#ErrorCode] )
else
put string(msg) & RETURN
end if
end
To establish connection with the server use:
net = xtra("multiuser")
-- Create new client instance
mus = net.new()
-- Prepares messages handler
mus.setNetMessageHandler( #defaultCallback, script("NetHandler") )
-- Connects to the server
mus.connectToNetServer( "SenderId", "", "host", 4545, "MovieName" )
On connectToNetServer method multiuser xtra sends a message with subject "Logon". Server side Lingo should reply to this message to make multiuser xtra think it is connected successfully. After this reply is received you may send usual messages to server and handle messages posted back to client.
-- Prepare data to be sent
valSomeLingoValue = [ 1, 2, "3", [1, 2], [#propName:propValue], #etc ]
mus.sendNetMessage( "Dummy", "Subject", valSomeLingoValue )
Reply will be handled by "NetHandler" parent script object.
|