=====================================================================
	Sample ActiveX Exe Server Documentation
=====================================================================
Author : Mrugendra Bhure (mrugendra999@yahoo.com)

Instructions:
	a) First open the Project MyServer.vbp and run It using Run->start
	b) Open the Client.vbg project group (do not open individual projects) and run it.
	c) Press on ConnectToServer button
	d) Press on the Get Employee Record button, this should fetch the data.
	e) On the Server Monitoring Form, try sending messages, Shut down clients etc.
	f) A message box should be displayed on the client machine when a message from the server 	   is sent.
	g) You can also use the broadcast button to send  messages to all clients.
----------------------------------------------------------------------------------------------
Documentation
Here is the true client server project example just for You.
This sample consists of Two Parts
1) The Server (ActiveX Exe Project - prjMyServer.vbp)
2) The Client Part (client.vbg)


1) The ActiveX Exe Server Part
This part of the program will run on server machine. And will Act as the gateway for data to all the clients.

The Server consists of the following class modules
a) clsSever : 
===============================================================================
This module is the main module of the server and clients will be creating objects of this module. This module consists of the following methods.

1) Login(UserName,Password,clbkClient as Object,WorkStation,ErrMsg) as Boolean
----------------------------------------------------------
		This function as clear from the name , performs the login for clients, without which no data will be provided to them. The clients will have to pass their loginName,Password, MachineName(optional) and one String Object ErrMsg that will contain any error messages occured while performing login.
The clbkClient object is a callback class which allows the server to use its methods to send messages to this perticular client.

2) GetEmployeeRecord() as Recordset
----------------------------------------------------------
This method will give the client a recordset that will contain all the details of a employee. This is a sample table in the database. Note that the recordset provided is Disconnected meaning that the client can not directly update data directly, this assures security. For updating data the client has to submit the recordset to the server for processing (if any and authentication) by using the method SubmitData(rst as recordset).

3) SubmitData(rst as Recordset)
----------------------------------------------------------
This method updates the database with the changes that the client has made to the record. The database would not be updated until this method is called. You can also perform Transaction Management here.

4) UpdateUserList()
----------------------------------------------------------
This is a private sub which refreshes the Userlist provided as a listview in the main Form, on login and logout of the client.

==============================================================================================

b) ServerClient (Interface)
==============================================================================================
This is not a module but rather an interface. It consists no implementation of the methods but only declaration. Now you will be wondering for what this?, wel, this is necessary for a mechanism called as Callbacks, which allows communication and Object transfer between client and the server. See the disconnect Select Client,Send Message buttons in the mainform of the server, this functions are implemented using this technology.  This interface is implemented by the client in the client program and passes this implementation class to the Login function so that the server can later call its methods to send messages and shut down info.

c) UserInfo
==============================================================================================
This class is a class which stores all the user information provided by the user at the login time and becomes an active member of the Users collection.


Note: 
This server program is optimized by using following techniques.
1) All the clients share the same connection to the database.
If the data traffic is not too great then a single connection object can serve multiple clients thus saving RAM. There is no need for new connection for each client.
2) Thread For each Client.
Using this technique, if one client becomes busy, it does not hamper the performance of other as each of client has got its own thread. Also no variables are shared between client,as each thread gets its own set of variables. This can be heavy on RAM when there are hundreds of clients, but its critical as far as security is concerned.


===============================================xxxxxxxxxxx===================================
2) The Client Part
The client part is a project group consisting of a Standard Exe Project and an ActiveX DLL Project.

The standard exe project acts as the client for the server and creats its object. It uses the ActiveX DLL object as a parameter to Login Function. This is a part of callback mechanism which allow client-server communication.

Note that the client uses the CreateObject(classname,MachineName) function to crate the object of the server. This is required when the server and the client reside on different machines or if the you want to create the objects of the currently running server.

To create objects of the server which resides on the Machine named MachineX , alter the createObject function used in the main form of the Standard Exe to
	set ObjServer = createObject("MyServer.clsServer","MachineX")
Note: You can also use the IP address of the Machine instead of the machine name.
===============================================xxxxxxxxxxxx======================================

There are many other issues related to this kind of client server implementation so there is a lot to discuss later. I have poured-in all my experience of Client-server to create this example, so there should be no problems as regards implementation.



