Class ClientManager



    Purpose

    Each client has a corresponding ClientManager in the server part. When the server wants to communicat with a client, it should communicate through the ClientManager.

    A ClientManager keeps the client ID, and the two sockets (one for map message and the other for action message) between the client and the server.

    Each ClientManager also have a MessageReceiver and a MapReqReceiver to get action request messages and map request messages from the client.

    Functionality

    A ClientManager is a thread. After the server starts, it generates a ClientManager and waits for a client connecting to the server. Once a client is connected, the ClientManager will generate another new ClientManager waiting for another client to connect. Then it will assign a unique ID to this client and records this ID. The ClientManager will keep the four sockets between the server and the client. This ClientManager will broadcast the information of this new client to all other existing clients and get their information through their ClientManagers.

    Structure

    A ClientManager keeps four sockets: one for sending and receiving map related messages; one for sending and receiving action related messages; and two for talk related messages.

    Two threads MessageReciever and MapReqReceiver: These two threads start right after a client connects to the server and each are responsible for receiving action request messages and map request messages from the client.

    Two threads tst1 and tst2: These two threads of the class TalkServerThread are responsible for talk requests. They starts when a talk request is made. They are used in the method handleTalking().

    See also

    MessageReceiver
    MapReqReceiver
    ServerConnection




    [Go to Class Index Table] [Go back to Program Architecture Diagram]
    [Source Code of ClientManager.java]