Friday 8 February 2008

Working on the database

I finally startet with some real database work. Till yet I only had a small Dummy Connection which was just enough to simulate a login and the buddyList transfer to the client. The last work on the clients side was to send a message.  This required to work a little more on the server so I decided to now stick with the server and start with the DB. During my work on the I had to add two components into the DB.
  • A chat object with a userlist within the chat.
  • A Database Log to allow communication between both servers.
I got the idea with the Database Log when I startet with messages. The easiest way wold be that each client would regularly poll the DB and to check whether anything has changed (new messages, new buddies,...). How am I planning to implement it? The design is not finished yet but I already got the main concept. Each time a buddy request, message or other user related event occurs, it will be logged into the Log Table. On the TCP or Socket based server one static class with a separate DB-Connection would query this table and notify all client handlers using MVC about those changes. In this case the entry would be delted from the log. In order to keep this method efficient, all entries older than  a minute will be deleted. At the moment I have to think about how to log the events and which events. Currently I am thinking of Storing it in the following Format: LogID, Time, User, Event The Event would be something very basic like "Received Message" and the notified user handler would check all received messages for this user within the db.

No comments: