Joins an AGK network hosted by another app.
class function Join(const Owner: TAgkObject; const NetworkName: String; const ClientName: String): TAgkNetwork; overload; static;
Parameters |
Description |
const Owner: TAgkObject |
the owner of the network object (eg. a TAgkApplication object). |
const NetworkName: String |
The name of the network to connect to. |
const ClientName: String |
The name to use in identifying this client. |
The network is specified by network name if you are on the same LAN as the host. In the case of internet connections IP and port is the only way to connect as broadcasts will not leave the local area network (see the other Join overload).
This function does not connect immediately. It continues to attempt to connect in the background. You can detect when a connection is made by checking that ConnectionCount is greater than 1. This app itself is included in the client count, and the host also counts as a client. If IsActive returns False at any time then the connection to the server failed and the network should be closed (by freeing this object). You may attempt to reconnect by opening a new network.
Once connected the app becomes a client of the network, along with the host and any other clients that have connected to it. All clients are treated equally and have a list of local variables that they can read from and write to, all clients can also read any variables on other clients on a read only basis.
Copyright (c) 2012. All rights reserved.
|