Peer connection examples using the Director Multiuser Xtra
The included Peer-to-peer example Director 7 movie demonstrates the basic ways to make peer network connections directly between two systems using the Director Multiuser Xtra.
The movie has been designed to establish these connections in 3 typical ways:
| |
Connecting to another instance of the movie which is in "Wait mode". |
| |
Placing an instance of the movie in "Wait mode" and awaiting a connection from the movie in #1 above. |
| |
Meeting on a separate Director Multiuser Server and then pairing off with a peer connection. This method only connects to the server briefly while the peer address information is exchanged by the two movies. |
Instructions for the included movie
To connect two computers directly as peers, do the following:
| 1 | Start the movie on both computers. |
| 2 | On one, click the "Wait For Connection" button. This computer will eventually accept incoming connections. |
| 3 | On the other, click the "Connect To Other Computer" button. This system will connect to the first computer. |
| 4 | On the waiting computer, make a note of the computer's IP address and press "Start Waiting". |
| At the other system, enter the waiting computer's IP address or its computer name ("mycomputer.company.com", etc.) and press "Start Connection". For both systems, you don't have to change any of the user names or passwords, though you may if you wish. |
|
| The two systems should connect and both go to the "Testing Peer Connections" screen. You can click on the buttons to send messages to the other system or yourself. |
Meeting on a separate server and then pairing off to a peer connection
The movie also demonstrates the basic techniques for connecting to a server, then negotiating between two computers to connect directly, making the direct peer connection and then breaking off from the server.
To connect to a Multiuser server and then pair off into a peer connection:
| 1 | Press the "Meet on a Server" button in both instances of the movie. You must have a running Director Multiuser Server that is configured to accept connections for this movie and the usernames you provide. The default Multiuser.cfg file that comes with the server will allow any movie with any user to connect to the server. |
| 2 | Enter the appropriate information in both instances of the movie, using two different user names. |
| 3 | Press the "Connect to Server" button. Both movies will connect to the server. |
MeetOnServer and MeetScript
The logic to do this type of connection is contained in the"MeetOnServer" loop, which includes the behavior "MeetScript", and in the message handlers.
The structure (non-literal) of this looks like:
Connect to the server.
Get a list of all the connections on the server for this movie with the "GetGroupMembers" command.
If someone else is connected to the server,
send an invitation to the other system to connect to us with a"ConnectToMe" message. The invitation includes our IP address cookie from the GetNetAddressCookie() function. Wait for the invitation reply, an "RSVP" message.
else
Wait a bit and go look for other connections again.
If the other system accepts our invitation,
start waiting for incoming connections
send them a "GoAheadAndConnect" message
break the connection to the server. else If the other system declined the invitation to connect,
go back to the start to find someone to connect with. If we get an invitation to connect (a "ConnectToMe" message), and we're not busy
negotiating another connection,
send them a "RSVP" message accepting the invitation
wait for a "GoAheadAndConnect" message
when that arrives, connect to the system
break the connection to the server else send them a "RSVP" message rejecting the invitation
Timeout Checking
The lingo code to execute this could be improved with some timeout checking.If any of the negotiation steps take too long, the system should revert back to the starting step.
This is important because the movie may get shutdown or connections broken during the process, potentially leaving another movie waiting indefinitely for a response.
Note:This is just one of the many ways to create this functionality in Director.
This download contains the following file:
| |
testpeer.dir |
Download the Windows zip file
Download the Macintosh sea file
This content requires Flash
To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Download the free Flash Player now!
