MsgCommunicator: Delphi Instant Messaging (IM) SDK
for easy creation of custom messenger system


Top  Previous  Next

To start the work in client/server mode, you should connect to the server first. Most of all methods of TMsgClient required connection to server to be set. If you will call such a method while Disconnected property being set to False, it will implicitly connect to the server then execute some commands and disconnect to save current Disconnected status. So in this case you will have additional network connect/disconnect traffic and a risk to get incorrect result due some changes on the server can take effect (for example, some user can get your UserID before you register).

In case you have a user already registered at the server and would like to login, set UserID property first. Then, if you would not like to change any connection parameter, just call Connect method of TMsgClient component or set Connected property to True.

In other case it is the first time you will connect to the server, you can start with connect procedure leaving UserID set to default value. In this case UserID will be set to the next available value by server after connect process will be complete.

If you would like to get specific number, you can check for the available ID by calling IsUserExisting then set UserID to this number if it is available. Note that there is a chance that another user will have got it first.

When you have connected to the server for the first time and obtain your unique UserID at this server, you should prepare UserInfo (you must set UserName at least) then register it by calling TMsgClient.RegisterNewUser to add your user details to users database at server. In other case you disconnect without registration, your current UserID will be available for any user to register with it. You can read details about registration process in the next chapter, Working with user details.

In case you get error like 'Cannot connect for X retries...' while try to set connection, it means that your network is overloaded. Try to increase ConnectRetryCount, ConnectDelay, or both these parameters in TMsgClientNetworkSettingsEditor.

If your server is not accessible to connect, you will give error message which contains connected parameters used to connect. In this case you can be sure that your server is working and network is configured properly (see Networking chapter for details). Another reason could be incorrect connection parameters, for example, TMsgClientConnectParamsEditor.RemotePort of TMsgClient is not corresponded with TMsgServerConnectParamsEditor.LocalPort of TMsgServer.

Note:When you start a server, be sure that local port you plan to work on is not in use, for example, by another copy of MsgCommunicator application you started before. If the local port you specified is already used, the component, TMsgClient or TMsgServer, implicitly change its local port to the next available number. It is implemented to allow simultaneous work of some copies of the application you created without need to re-compile it.  
Note:If you change UserID while TMsgClient.Connected is set to True, it implicitly calls Disconnect then MsgClient will try to connect again with new UserID value.  
Further topics:  
Direct Messaging  
User details and users database  
Working with contact list  
Custom commands  
Peer-To-Peer Mode  
Writing server application  

© AidAim Software MsgCommunicator: