Can I get away with this or is it just too crude and unpractical ?
- by The_AlienCoder
I spent the whole of last night searching for a free AspNet web chat control that I could simply drag into my website. Well the search was in vain as I could not find a control that matched my needs i.e List of users, 1 to 1 chat, Ability to kick out users..
In the end I decided to create my own control from scractch. Although it works well on my machine Im concerned that It maybe a little crude and unpractical on a shared hosting enviroment.
Basically this is what I did :
Created an sql database that stores the chat messages.
Wrote the stored procedures and and included a statement that clears old messages
Then the 'crude' part :
Dragged an update panel and timer control on my page
Dragged a Repeater databound to the chat messages table inside the update panel
Dragged another update panel and inside it put a textbox and a button
Configured the timer control to tick every 5 seconds.
..and then I made it all work like this
In the timer tick event I 'refreshed' the messages display by invoking Databind() on my repeater i.e
protected void Timer1_Tick(object sender, EventArgs e)
{
MyRepeater.DataBind();
}
Then in my send button click event
protected void btnSend_Click(object sender, EventArgs e)
{
MyDataLayer.InsertMessage(Message, Sender, CurrTime);
}
Well It works well on my machine and Ive got the other functionalities(users list, kick out user..) to work by simply creating more tables.
But like I said it seems a little crude to me. so I need a proffesional opinion. Should I run with this or try another Approach ?