Multiuser Server


[ Zettels Traum ] [ search / suche ]

BAE wrote:

Here is some completely preliminary, most likely error-riddled, unformatted
set of Multiuser docs. Corrections and feedback welcome.

Please send any feedback to mailto:multiuser@zeusprod.com, and bear in mind
that the code below is completed untested and taken from scattered postings
and pseudo-documentation much of which could be wrong, outdated or both.

Also note that there are some tricks for using it with firewalls which I
have not covered.

Copyright Bruce A. Epstein 1998. All Rights reserved.


Multiuser Server

See the Internet>Multiuser Behaviors under Window>Library Palette, or see
the source code at Director 7/Libs/Internet/Multiuser.CST for examples that
use the Multiuser Xtra. For Macromedia's documentation, see
http://www.macromedia.com/support/director/how/subjects/multiuser.html (not
yet active).

See http://www.zeusprod.com/nutshell/chapters/multiuser.html for an
overview of the multiuser server (not yet active).

PowerPC and Win32 versions of the Mars multiuser server ship with D7. UNIX
and Linux versions are anticipated. You can allegedly hook two machines
peer-to-peer and have them talk as well. One has to use
WaitForNetConnection, while the other
uses ConnectToNetServer()

Be sure to define a callback handler with SetNetMessageHandler()  before
you do anything else.

Messages are sent to the handler defined by SetNetMessageHandler() and take
the form:

[#errorCode: errorCode, #recipients: "users",   #senderID: "senderName",
#subject: "subject",  #content: content, #timestamp: time]


where #errorCode can be interpreted using getNetErrorString() and 0
indicates success.

The #senderName is either "System" or a user name.

The #subject is the message type, such as "ConnectToNetServer".

The #content is specific to the message type and can be any of these types:
Void, Integer, Symbol, String, Picture, Float, List, Point, Rect, PropList,
Color, Date, Media

Table 1 lists the new Lingo elements of the Multiuser Server that can be
used to implement a chat room, multiplayer game, or multiuser database.

The Multiuser Xtra's methods can also be viewed in the Message window using:
put mMessageList (xtra "Multiuser")

Table 1: Multiuser Xtra Commands

muObj = new (xtra "Multiuser")
        Creates a Multiuser object instance

BreakConnection(muObj, "userID")
        Breaks a peer connection

CheckNetMessages(muObj)
        Processes waiting messages and calls the handlers specified by
SetNetMessageHandler().

ConnectToNetServer (muObj, "userID", "password", "server.domain.com",
portNumber, "movieID" {, mode})
          Connects to a server. PortNumber is usually 1626. Sends property
list to handler specified by SetNetMessageHandler().


GetNetAddressCookie(muObj)
        Obtains an encrypted cookie allow peer-to-peer connections without
exposing a machine's IP address.

getNetErrorString (muObj, errorCode)
        Returns the string for an integer error code. 0 indicates success.
See D7 Lingo Dictionary for list of codes.

GetNetMessage(muObj)
        Returns the oldest net message in the queue.

GetNetOutgoingBytes (muObj)
        Returns the size of the outgoing overflow buffer, or a peer
connection's outgoing overflow buffer

GetNumberWaitingNetMessages (muObj)
        Obtains the number of unread messages

GetPeerConnectionList(muObj)
        Obtains a list of peer connections.

SendNetMessage (muObj, toWhom, command {, params})
        Sends a command to toWhom., such as "System",
"@AllUsers","@AllServerUsers", or a specific user name. Table 2 shows
messages recognized by the "System"

SetNetBufferLimits (muObj, bufferSize, maxMessageSize, maxQueuedMsgs)
        Sets memory and message maxima.

SetNetMessageHandler (muObj, #handlerSymbol, instance {, params})
        Sets the event handler within a script instance that is called when
a server message is received. Assign this before using any other commands.

WaitForNetConnection (muObj, "userID", localPortNumber {, maxConnections})
        Waits for connection from another computer using
ConnectToNetServer(). LocalPortNumber is usually 1626.
#userId, #password, and #movieID are returned in #content list.


Table 2 shows messages that can be sent to the multiuser server using
SendNetMessage(), such as:

groups = sendNetMessage (muObj, "System", "getGroupMembers", "someGroup")

The commands pertaining to databases (grouped at the end of the table)
assume that you have an optionally indexed database residing on the server.
You must use a separate database program, such as FoxPro or MS-Access to
create and index such a database, which should be in .DBF format.

Table 2: SendNetMessage "System" Commands

Command and Parameters that must be included with the sendNetMessage command.
      #Content property or #errorCode property in message sent to handler
defined by SetNetMessageHandler() contains the stuff shown on the next
line...

"disableMovie", "movie"
        Error code, or 0 for success.

"disableUser", ["user", "movie"]
        Error code, or 0 for success.

"disconnectUser", ["user", "movie"]
        Error code, or 0 for success.

"enableMovie", "movie"
        Error code, or 0 for success.

"enableUser", ["user", "movie"]
        Error code, or 0 for success.

"getGroupList", EMPTY
        List of group names (strings).

"getGroupMembers", "group"
        List containing group name followed by group members.

"getListOfAllMovies", EMPTY
        List of connected movies.

"getNewGroupName", 0
        Unique group name.

"getNumberOfMembers", "group"
        Number of members in group

"getServerMilliseconds", EMPTY
        Synchronization time in milliseconds.

"getServerTicks", EMPTY
        Synchronization time in ticks.

"getServerTime", EMPTY
        Synchronization time in milliseconds.

"getServerVersion", EMPTY
        Server version string.

"getUserGroups", EMPTY
        List of groups including predefined groups.

"getUserIPAddress", "user"
        Property list, [#userID: "user", #ipAddress: "123.45.67.890"]

"joinGroup", "group"
        Message of the form
[#errorCode: errorCode, #senderID: "userID", #subject: "joinGroup",
#content: groupName]

"leaveGroup", "group"
        Message of the form [#errorCode: errorCode, #senderID: "userID",
#subject: " leaveGroup ", #content: groupName]

Database commands:

"getFields", "#field" | ["#field1", "#field2"]
        Property list of field symbols and their values.

"getReadableFieldList", 0
        List of fields that can be read from a database.

"getRecordCount", 0
        Number of records in database.

"getRecords", numRecords
        List of the next numRecords records.

"getWriteableFieldList", 0
        List of fields that can be written to database.

"reindex", "file"
        Reindex an existing indexed database.




Bruce Epstein, Zeus Productions, mailto:bruce@zeusprod.com
Check out the D7 FAQ: http://www.zeusprod.com/nutshell/d7faq.html
===============
"Lingo in a Nutshell" (LIAN) makes a great stocking stuffer:
http://www.zeusprod.com/nutshell/ordering.html
Buy LIAN at Computer Literacy (they dropped their price to $15.95!)
http://www1.clbooks.com/FindItNow/Services/PYG725/home.cl?from=PYG725
Buy LIAN from Amazon.com and/or submit your review of it at:
http://www.amazon.com/exec/obidos/ASIN/1565924932/zeusproductions
================























D. Plänitz