Multiuser Xtra
Contents
Check messages at a Regular Interval
In order to get the best performance from a connection you should check messages at regular interval using the checkNetMessages function. You cannot call this function from a frame event, so you should create a timeout object that regularly calls the checkNetMessages function. The example below presupposes that a instance of the Multiuser Xtra with the name "MUServer" has been created within a parent script.
--Create the timeout object. Do this right after you have established --a connection. This timeout will check incoming netmessages every 40 ms. oTimeout = timeout().new(string(me), 40, #checkNetMessages, me)
--The handler that is called should look like this: on checkNetMessages me MUServer.checkNetMessages() end
--Jsiponen 01:46, 18 Jul 2005 (MDT)
Enabling UDP in version 3.0
UDP support was added with version 3.0 of the Shockwave Multiuser Server. It does not work by default so this is what you need to do in order to enable it.
Edit the Multiuser.cfg file
Firstly you will need to edit your "Multiuser.cfg" file that resides in the same folder as the server application (MultiuserServer.exe). The following line should be uncommented in the cfg-file (uncommenting is done by removing the '#' in front of the line):
#UDPServerAddress = 127.0.0.1:1627
After uncommmenting the above line you will need to specify the IP-address of the computer that is hosting the server (i.e 127.0.0.1 should be replaced with the computer's IP-address) and keep the port number (:1627) at its default, but it should work with another port as well.
After this you should uncomment the following line in the cfg-file:
#EnableUDP = 1
Make sure that the value after EnableUDP is 1.
Save the configuration and restart the MultiuserServer if it is started.
Connecting to the Server as an UDP Enabled Client
An example of establishing a connection to the MultiuserServer as a UDP enabled client is shown below.
--create a instance of the Multiuser Server Xtra: MUServer = xtra("Multiuser").new()
--Save the local IP-address localIP = MUServer.getNetAddressCookie(false)
--Create a property list that contains the information necessary to logon as --a UDP-enabled client.
logonData = [\ #logonInfo:\ [#userID:"user", #password:"pw", #movieID:"id"], \ #remoteAddress:"127.0.0.1", \ #mode:#smus, \ #localUDPPort:1627, \ #localAddress:localIP, \ #remoteTCPPort:1626]
--Connect to the server using the logonData errCode = MUServer.connectToNetServer(logonData)
--Check that the errorCode isn't less than zero because that indicates that --an error occured
if errCode < 0 then --If an error occured then alert the user/developer about what occured alert MUServer.getNetErrorString(errCode) end if
Sending UDP-Messages
In order to send an message using UDP you must include the property UDP in the message and set its value to true. Example below:
errCode = MUServer.sendNetMessage([#recipients: "Username", #subject: "locationData", #content: point(0,0), #UDP: TRUE])
--Jsiponen 01:46, 18 Jul 2005 (MDT)