Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Chat Server DBI – Representation and Management of Data on the Internet.

Similar presentations


Presentation on theme: "A Chat Server DBI – Representation and Management of Data on the Internet."— Presentation transcript:

1 A Chat Server DBI – Representation and Management of Data on the Internet

2 A Chat Server Example Gives an example of how to combine the client and the server application into one combined system The Chat application gives a group of remote users the ability to ‘talk’ to each other through a server

3 A Real Chat Room Commercials advertisements

4 Chat Server Listens on a port Accepts connections Spawns threads, one per connection Receives a message from one client Dispatches it to all clients

5 The Objects of the Server ChatServer –main ClientHandler –one per connection –threaded Dispatcher –vector

6 Chat Server Objects (Diagram) ChatServer ClientHandler Dispatcher Socket

7 ClientHandler In the running loop: –Generates filter streams –Reads a message line –Sends the messages to the dispatcher On another client message: –Get the message from the dispatcher –Sends the message to the client using the socket to the client

8 Dispatcher Keeps a list of all client handlers On a client message (sends the message to all clients): –Accepts a String and an identifying integer –Enumerates down all client handlers and calls each one’s send() method

9 ChatServer Creates a new ServerSocket Creates a new Dispatcher Listens for connections When connection received, creates a new ClientHandler and starts it as a new thread Adds it to the Dispatcher

10 The Code ChatClient.java ChatServer.java ClientHandler.java Dispatcher.java

11


Download ppt "A Chat Server DBI – Representation and Management of Data on the Internet."

Similar presentations


Ads by Google