I am trying to develop a chat application.I am using Asp.Net2.0 and vs2005.Iam using AjaxPro Framework for getting asynchronous calls to the server side.
My problem is when i send message im getting timeout error after a few seconds.What could be the problem and how will i resolve it?
My another doubt is that is there some serious problem in using AjaxPro Framework
Heres the code i have used in the client side to send messages
// Send messages
function sendMessage()
{
// input box for entering message
var ta_content = el("txtcontent");
// if the content input is not empty
if (ta_content.value.length > 0)
{
//the message show area
var div_recentMsg = el("recentMsg");
var clientUname=document.getElementById("").value;
var adminUname=document.getElementById("").value;
// send the message
AjaxProChat.SendMessage(clientUname,adminUname,ta_content.value);
// clear the input box
ta_content.value = "";
// roll up the web page with the messages
ta_content.scrollIntoView(false);
getNewMessage();
}
}
//Obtain the new messages
function getNewMessage()
{
// AjaxProChat.timeouPeriod(1800000);
// the user name
var username = document.getElementById("").value;
// the message show area
var div_recentMsg = el("recentMsg");
// Obtain the DataTable for the newest messages
var dt = AjaxProChat.GetNewMsg(username).value;
for (var i = 0;i < dt.Rows.length;i++)
{
// one message in response to one object
var oneMsg = document.createElement("span");
// the message sender and corresponding sent content
var strLine1 = dt.Rows[i].Sender + " says: (" + dt.Rows[i].SendTime + ")";
strLine1 = DealBrackets(strLine1);
// the content of the message
var strLine2 = dt.Rows[i].Contents;
strLine2 = DealBrackets(strLine2);
// show style
oneMsg.innerHTML = "
" + strLine1 + "";
" + strLine2 + "
oneMsg.style.padding = "2px 2px 2px 2px";
oneMsg.style.color = (dt.Rows[i].Sender == username) ? "blue" : "red";
oneMsg.style.fontFamily = "'Courier New'";
// attached to DOM
div_recentMsg.appendChild(oneMsg);
}
}
Heres the html code
Chatting Room
Input the message and click Send or press ENTER key: | ||
style="width: 55%; height: 30px" type="text" runat="server" /> | ||
Heres the code for sending and receving messages i have written in server side
[AjaxPro.AjaxMethod]//code for sending messages
public void SendMessage(string Sender,string Receiver,string Content)
{
ChatBAL clsChat = new ChatBAL();
clsChat.SENDER = Sender;
clsChat.RECEIVER = Receiver;
clsChat.CONTENT = Content;
clsChat.SendMessage();
}
[AjaxPro.AjaxMethod]//code for getting latest message and returns datatable
public DataTable GetNewMsg(string UserName)
{
ChatBAL clsChat = new ChatBAL();
DataTable dtNewMsg =new DataTable();
try
{
clsChat.USERNAME = UserName;
dtNewMsg = clsChat.GetNewMessage();
}
catch
{
throw;
}
finally
{
clsChat = null;
}
return dtNewMsg;
}