What's New in Director 8.5 > Using the Shockwave Multiuser Server and Xtra > Creating multiuser movies > Setting up peer-to-peer connections

 

Setting up peer-to-peer connections

In some situations, you might prefer to design your movies to communicate directly with one another. By using the peer-to-peer functions of the Multiuser Xtra, you can set up one instance of a movie as a virtual server, or peer host, and connect up to 16 other client movies to it. This method lets you set up private chats, create games for limited numbers of users, or make presentations to small groups, without using a server. The disadvantage of using peer connections is that you do not have access to the server's group, database, or administrative functions.

One of the movies in a peer-to-peer connection must be the host. You set up a movie to be a peer host by using waitForNetConnection. Once the movie is in peer-host mode, other movies can connect to it in the same way they connect to the server using connectToNetServer.

Movies that wish to connect to a peer host must know the Internet address of the computer the host movie is running on. This will be either a number, such as 192.98.168.1, or a name, such as myServer.myCompany.com. You can get the numeric Internet address of your computer with getNetAddressCookie. By default, this function returns an encrypted version of your IP address. In addition, getNetAddressCookie can return an unencrypted result, but only in projectors and the Director authoring application. One way to make the address available to other users is to meet them on the server and then send them your Internet address cookie before making a peer connection.

You send messages in peer-to-peer mode in the same way as when connected to the server. You can send messages directly to other peer users or to the peer host. Messages sent to other peers are routed to the recipient by the Xtra in the host movie, but their contents are not made available to the host movie. Only messages sent to the host user or to @AllUsers are actually received by the host as messages that can be accessed in Lingo. In peer-host mode, the Xtra does not provide any of the server features such as group management or database access.

Peer hosts can control who is connected to their movie by keeping track of the list of connected users and breaking connections if necessary. Using getPeerConnectionList, you can get a list of the current peer connections on a peer host. You can sever the connection of a specific user in the list by using breakConnection.

When implementing a peer-to-peer movie design, you may choose to make one Director movie that always acts as a host and another Director movie that is used for the clients. You may also choose to author your movie so that it can function as either host or client, allowing anyone who uses the movie to initiate the peer-to-peer session.

Keep in mind that because all peer messages are routed through the peer host, there will be an extra CPU burden and network throughput required on that machine. The degree of this burden will depend on the size and number of messages your movie sends and the number of peers connected to the host. For ways to minimize this load, see Optimizing multiuser movies.