MsgCommunicator: Delphi Instant Messaging (IM) SDK
for easy creation of custom messenger system
To start the work in client/server mode, you should connect to the server first. If you have registered user, you can logon to get the full access to the server, in other case you will work as a guest (UserID=MSG_INVALID_USER_ID). If you are connected but not logged, you can do the user search and registration only. The following functions allowed to all guests: Logon, RegisterNewUser, IsUserExisting, FindUsers.
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 (including the case of a user has no password, in other case you should specify Password property at least), just call Connect method of TMsgClient component or set Connected property to True. Connect method implicitly calls Logon. If you set properly Password for a user with this UserID, this user will be logged on the server. If you specify wrong UserID or Password, user will be connected only and will not be logged. In this case Logged property will be set to False and UserID will be equal to default value MSG_INVALID_USER_ID (despite of the UserID value you set) to indicate guest mode. If Logon is successful, Connect method get contacts list from the server that is available via Contacts property.
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.
If you would like to get any specific number, you can check for the available ID by calling IsUserExisting then, if it is available, specify UserID to this number in UserInfo you prepare to registration. Note that there is a chance that another user will have got it first. In this case you'll get an appropriate error code as a result of RegisterNewUser.
When you have connected to the server for the first time, you should prepare UserInfo (you must set UserName at least; set UserInfo.UserID to MSG_INVALID_USER_ID default value to obtain your unique identifier at this server or to another number you would like to register) then register it by calling RegisterNewUser to add your user details to users database at server. RegisterNewUser implicitly calls Logon to get the full access to the server. 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:||You cannot change UserID property while the client is Logged or Connected or Active.