高分求asp.net聊天室源码
各位高手,
小弟急着交点东西,需要聊天室源码,必须是asp.net做的,最好无刷屏 啊。
如果有详细制作步骤,更好啊!
希望哪位能伸出援助之手!
定将高分相送!
我的邮箱:tongxi315@163.com
非常感谢!
问题点数:80、回复次数:7Top
1 楼minghui000(沉迷网络游戏)回复于 2005-01-26 21:06:18 得分 50
Creating the webservice:
As mentioned earlier, in a Peer to Peer application, the server support is needed for three actions - registering the peers, receiving messages for routing and passing on waiting messages. Therefore, our web service will have three Web Methods:
public string RegisterMember(String NickName)
public ChatMessage XchangeMsgs(String NickName, String Msg)
public ChatMessage GetMsgs(String NickName)
The web service is encapsulated in a class called ChatWebService, which is derived from System.Web.Servicesand is contained in the source code fileChatWebService.cs in the namespace PrasadWeb. The namespace also defines two other classes calledMember and ChatMessage. The classMessage has a string variable called UserName, a DateTime variable calledLastAccessTime and a public property NickName, which gets and sets the variableUserName together with the time of his registration. The ClassChatMessage has merely two string variables calledUserList and Messages. These two variables hold formatted lists of Chat Participants and the undelivered chat messages at any given time.
The main classChatWebService has two private methodsString GetMemberList() and Void CheckMemberList(), besides the three Web Methods mentioned earlier. The former function returns the list of chat participants at any given time as a formatted list. The later function checks to see if any chat client has been absent from the circuit for more than 2 minutes and removes him from the chat list, so as to keep the environment free from quitters. TheGetMemberList function works as follows:
public String GetMembersList()
{
// We need to lock the app to enable syncronization
// The variable for the return message
String UserList = "";
// Every web application has an Application property
// which yields a handle to the ApplicationState object.
// ApplicationState object stores the collection of
// Member Objects (we will see latter how we do it).
// We obtain an array of the Keys to the collection
// and store the array in a variable 'Members'
String[] Members = Application.AllKeys;
// We can now unlock the application
Application.UnLock();
// Now we read the UserName variable in each Member
// object found in the HttpApplicationState State Collection
// and store these values in a string separated by
// NewLine Characters
for (int x=0;x
As the application involves multiple users - all accessing the same set of variables stored by us in the application object - we need to use Code Synchronization by invoking theLock andUnLock methods of theSystem.Web.HttpApplicationState State object whenever a write operation is performed by us.
In theRegisterMember method, we first check if the username supplied by the client is unique - if not, reject the name. Then, we instantiate a newMember object for the new participant and add the object to theApplicationState objects collection. We do these with the following code:
public string RegisterMember(String NickName)
{
CheckMembersList();
String[] Members = Application.AllKeys;
If ((Members.Length>0)&&(Array.IndexOf(Members,NickName)>-1))
{
throw new Exception("UserName Already Exists.
Please Select another name");
}
Member NewMember = new Member(NickName);
Application.Lock();
Application.Add(NickName, NewMember);
Application.UnLock();
return GetMembersList();
}
Again, all these are done in alocked state.
Whenever a client sends a message through theXchangeMsgs method, we first call theCheckMembers private method to update the list of chat participants in our collection. Then we check if the just received message carries a familiar Nick Name that is already registered with us. Then we loop through all theMember objects in our collection, open each of them and insert the just received message into theMessages variable of each of theseMember objects - after due HTML Formatting. Finally, we retrieve theMessages string stored in theMember object corresponding to the current client caller as the return value and empty theMessages variable of that object.
TheGetMsgs web method is similar to the above except that this method does not being us any new messages from the client and it is merely called to collect all the pending messages and the current list of chat participants.
Top
2 楼minghui000(沉迷网络游戏)回复于 2005-01-26 21:06:36 得分 0
Creating the Chat Client:
Our Chat Client is an HTML Web Page, which contains a table with 7 rows and one column. The first row contains the name of the Chat Application. The even numbered rows bear the captions and row number three contains the Chat Participants List whilst row five is for chat messages. The last row has a Text Box and a Submit button. Rows three and five house aelement within them, whosescroll property has been set toauto.
Attaching the WebService Behavior:
The table webservice behavior defined in the webservice_ver1.htc file, as follows:
id="service"
onresult="service_onmyresult();"
onready="this.style.visibility = 'visible';loading.style.display='none';"
border="0"
style=
"Background-Color:
White;Height:60%;
Border-Bottom:#A03399 solid 2px;
ForeColor:Black;
width:45%;
Behavior:url('http://localhost/dotnet/chatroom/webservice_ver1.htc');
Border-Left:#99ccff solid 2px;
Border-Right:#A03399 solid 2px;
Position:Relative;
Visibility:hidden;
Width:30%;
Border-Top:#99ccff solid 2px;
Table-Layout:Fixed;
Border-Style:#008080 solid 2px;">
The page has two script blocks of which one is invoked on theonLoad event of the window. This script block calls the use method of the webservice behavior by passing the URI of the webservice as a parameter as follows:
The other parameter supplied to the method is the name of the service ChatServe. The second code block initializes three variables called iCallID1,iCallID2 and iCallID3, to store the ID of the three web method calls. It also initializes anXMLDom ActiveX Object called Msg_XML, to enable us to store the SOAP messages returned by the web service.
When the user types his nick name in the Text Box and presses the submit button, an asynchronous call is made to the Web Service'sRegisterMember method, by invoking thecall method found in the webservice.htc. The method formats the SOAP request for theWeb Method, sends it to the web service host server using theXMLHttp object of theMSXML ActiveX object and returns the initializer for theiCallID1 variable. The DHTML Behavior ensures that when the webservice returns a SOAP Message from the server, anonResult event is fired upon the Table. The event handler for this event first checks up if the return value is an error message and if not, whether the return message is for the iCallID1. On passing these tests, the XML value of the result is stored in theXMLDom object called Msg_XML.
At this stage the XML returned by the server will resemble the following:
Prasad
Uriah
Charlotte
The Chat List in the return message, which isPrasad Uriah Charlotte is parsed out by applying the XPath pattern//UserList on the XML String and written into the table as the inner HTML of the Chat List panel as follows:
service_ChatList.innerText = service_MsgXML.selectSingleNode("//UserList").text;
The method then goes on to set a timer to invoke theGetMsgs method of the web service after 3 seconds. The return value of this method is parsed and placed as the inner HTML of the Chat List panel and the Chat Messages panel of the Table. This method sets up a timer to call itself once every 3 seconds.
Whenever the client types a message in the text box and presses the submit button, theXchangeMsgs method of the web service is invoked by the DHTML Behavior component. The return value of this method being similar to the one described above, is dealt with in the same manner.
This, in brief, is the designing of the client object. You will need to take a deeper look into theClientSide.html file given in the code download for this article to read the intricate details of the client side coding involved.
Top
3 楼minghui000(沉迷网络游戏)回复于 2005-01-26 21:07:10 得分 0
Making a control for the client side:
All that was described in the preceding section was the HTML code required to be supplied to the client browser. However, since ASP.NET is based on components, we need to make it easy for the web developer by encapsulating all these HTML code into a Control. Therefore, let us go on to create the ASP.NET custom control called TestWebControl. (See the code listing in the file TestWebControl.cs).
This control is derived from theSystem.Web.UI.WebControls.table object of the Framework. In it we override the protected method ofInit() and define various style elements for our component with the objective that the web developer using this control will have total say on how the control looks.
The properties we add to the control include oneBehaviorURI and one ServiceURI, which enable the control user to specify the URL of thewebservice.htc file on the server and the URI of the webservice. We, then, go on to instantiate new TableCell elements from the Framework, setting them with all the variables containing the css properties and finally adding them to our control - which is a sub class of the Table class. For this, we must first add the Table Cell into a newly instantiated TableRow element through its Cells Collection and the table row should be added to the Rows Collection of our control. Then, the client side scripts are all written into a string variable called Doc. An easy way of adding any script to the output document is to use theWrite Method of theHtmlTextWriter Object given to us when we override theRender Method. Therefore, to do the writing, we store the entire script block in thisDoc variable.
Finally we override the Render method of the Table class and write the scripts on to the client browser using theHtmlTextWriter object handed over to us by this method. We should not forget to call the base class'sRender Method, lest all our initialization code is left out of the page.
The Control thus created is used in any ASP.NET web form by inserting the following code: (You may change the URIs according to your server settings)
When running this application you will see a screen such as below that you can log on to and interact on.If you get someone else to log on to the page on to their computer you can have a conversation:
Summary
In this article we saw how to create a chat application using ASP.NET.Hopefully through this you will see the benefits of using ASP.NET for this sort of application and how by doing this you can avoid issues such as creating a server side listener.In this application you cannot log off yourself, but you can change the timing that people are logged on and inactive before being disconnected for longer than two minutes in the C sharp code.This article should help you develop your own ASP.NET chat applications.
[download relative material]Top
4 楼ghghzzzz(ghghzzzz)回复于 2005-01-26 21:58:40 得分 30
http://www.58down.com/soft/214.htmTop
5 楼minghui000(沉迷网络游戏)回复于 2005-01-26 22:46:56 得分 0
另一份
///ChatMessage.cs
using System;
namespace chat
{
/// <summary>
/// ChatMessage类封装了两个string变量:UserLists--用户列表,Messages--要传递的信息
/// </summary>
public class ChatMessage
{
public string UserList, Messages;
}
}
第二个我们要建立的是什么呢?一个聊天室应能存储在线成员的名字及访问时间
///Member.cs
using System;
namespace chat
{
/// <summary>
/// Member类为每个聊天者封装了Server端的变量
/// </summary>
public class Member
{
// 存储消息的队列
public string UserName, MsgQueue;
// 判断滞留事件以便踢人
public System.DateTime LastAccessTime;
// The constructor
public Member(string NickName)
{
this.UserName=NickName;
this.LastAccessTime=DateTime.Now;
}
}
}
接下来我们就应该做这个asmx了
///ChatWebService.asmx
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
namespace chat
{
/// <summary>
/// Summary description for ChatWebService.
/// </summary>
[WebService (Namespace = "http://localhost/chat/", Description = "This service provides an chat service")]
public class ChatWebService : System.Web.Services.WebService
{
public ChatWebService()
{
//CODEGEN: This call is required by the ASP.NET Web Services Designer
InitializeComponent();
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
}
[WebMethod(Description="接收用户名作为参数存储到Application对象中")]
public string Login(string username)
{
// Ascertain that all the registered chat participants are active
CheckMembersList();
// Synchronization Lock
Application.Lock();
// Get the collection of keys for the Application Variables
String[] Members = Application.AllKeys;
// Are there any registered chat members? & the present request is for a unique nick name?
if ((Members.Length>0)&&(Array.IndexOf(Members,username)>-1))
{
throw new Exception("该用户已存在!");
}
// Create a new Member object for this participant
Member NewMember = new Member(username);
// Add this new member to the collectionof Application Level Variables
Application.Add(username, NewMember);
// Synchronization unlock
Application.UnLock();
// Go and get the list of current chat participants and retrun the list
return GetMembersList();
}
[WebMethod(Description="GetMsg方法用用户名和消息为参数返回一个ChatMessage对象,包括要传递的消息和用户列表")]
public ChatMessage XchangeMsgs(string username, string Msg)
{
// Ascertain that all the registered chat participants are active
CheckMembersList();
// Synchronization Lock
Application.Lock();
// Get the collection of keys for the Application Variables
String[] Members = Application.AllKeys;
if ((Members.Length==0)||(Array.IndexOf(Members,username)==-1))
// Are there any registered chat members? & the present request is for a unique nick name?
{
throw new Exception("你当前可能没有登陆或登陆超时,请重新登陆!");
}
ChatMessage RetMsg = new ChatMessage();
RetMsg.UserList = GetMembersList();
// Loop through all the Chat Participant's serverside Member Objects and
// add the message just received in their waiting message queue
for (int x=0;x<Members.Length;x++)
{
Member temp = (Member)Application[Members[x]];
temp.MsgQueue+=("<BR><Font color = Red>" + username + " 说:<BR></FONT><Font color = Blue>" + Msg);
if (temp.UserName == username)
{
RetMsg.Messages = temp.MsgQueue;
temp.MsgQueue="";
temp.LastAccessTime=DateTime.Now;
}
}
// Synchronization unlock
Application.UnLock();
return RetMsg;
}
[WebMethod(Description="GetMsg方法用username为参数返回一个ChatMessage对象,包括要传递的消息和用户列表")]
public ChatMessage GetMsgs(string username)
{
Application.Lock();
CheckMembersList();
Application.Lock();
String[] Members = Application.AllKeys;
if ((Members.Length==0)||(Array.IndexOf(Members,username)==-1))
{
throw new Exception("Unknown User. Please Login with a UserName");
}
ChatMessage RetMsg = new ChatMessage();
RetMsg.UserList = GetMembersList();
Member temp = (Member)Application[username];
RetMsg.Messages = temp.MsgQueue;
temp.MsgQueue="";
temp.LastAccessTime=DateTime.Now;
Application.UnLock();
return RetMsg;
}
public string GetMembersList()
{
Application.Lock();
String UserList = "";
String[] Members = Application.AllKeys;
Application.UnLock();
for (int x=0;x<Members.Length;x++)
{
Member temp = (Member)Application[Members[x]];
UserList += (temp.UserName+"\n");
}
return UserList;
}
private void CheckMembersList()
{
String[] Members = Application.AllKeys;
ArrayList RemoveList = new ArrayList();
for (int x=0;x<Members.Length;x++)
{
Member temp = (Member) Application[Members[x]];
int test = (DateTime.Now.Subtract(temp.LastAccessTime)).Minutes;
if (test > 2)
{
RemoveList.Add(Members[x]);
}
}
// Users = null;
for (int count = 0;count<RemoveList.Count;count++)
{
Application.Remove((String)RemoveList[count]);
}
return;
}
}
}
Top
6 楼minghui000(沉迷网络游戏)回复于 2005-01-26 22:47:28 得分 0
server control,先来看一下代码
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
namespace Michael.Web.UI.Controls
{
/// <summary>
/// Summary description for chat.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:chat runat=server></{0}:chat>")]
public class chat : System.Web.UI.WebControls.Table
{
private string doc;
private string text;
[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
protected override void Render(HtmlTextWriter output)
{
// The script block is written to the client
output.Write(doc);
base.Render(output);
}
private string Serviceurl = "http://localhost/chat/ChatWebService.asmx?WSDL";
[Bindable(true),
Category("WebServiceProperty"),
DefaultValue("http://localhost/chat/ChatWebService.asmx?WSDL")]
public string ServiceURL
{
get
{
return Serviceurl;
}
set
{
Serviceurl = value;
}
}
private string Behaviorurl = "http://localhost/chat/webservice.htc";
[Bindable(true),
Category("WebServiceProperty"),
DefaultValue("")]
public string BehaviorURL
{
get
{
return Behaviorurl;
}
set
{
Behaviorurl = value;
}
}
private string tablecssclass;
[Bindable(true),
Category("LayoutProperty"),
DefaultValue("")]
public string TableCssClass
{
get
{
return tablecssclass;
}
set
{
tablecssclass = value;
}
}
private string titlecssclass;
[Bindable(true),
Category("LayoutProperty"),
DefaultValue("")]
public string TitleCssClass
{
get
{
return titlecssclass;
}
set
{
titlecssclass = value;
}
}
private string onlinecssclass;
[Bindable(true),
Category("LayoutProperty"),
DefaultValue("")]
public string OnlineCssClass
{
get
{
return onlinecssclass;
}
set
{
onlinecssclass = value;
}
}
private string msgcssclass;
[Bindable(true),
Category("LayoutProperty"),
DefaultValue("")]
public string MSGCssClass
{
get
{
return msgcssclass;
}
set
{
msgcssclass = value;
}
}
private string selusercssclass;
[Bindable(true),
Category("LayoutProperty"),
DefaultValue("")]
public string SelUserCssClass
{
get
{
return selusercssclass;
}
set
{
selusercssclass = value;
}
}
protected override void OnInit(EventArgs e)
{
this.ID = "service";
this.Style["Behavior"] = "url('" + Behaviorurl + "')";
this.Style["Table-Layout"] = "Fixed";
if( this.Attributes["class"] == null) this.Attributes["class"] = tablecssclass;
this.Attributes["onresult"] = UniqueID + "_onmyresult();";
TableRow tr;
// And also create 7 Table Cell elements one by one
TableCell cell = new TableCell();
cell.Attributes["class"] = titlecssclass;
cell.Attributes["Align"] = "Left";
// Set the caption of the control
cell.Text = "Portal 聊天室";
// Instantiate a Table Roa and attach the First Cell to it
tr = new TableRow();
tr.Cells.Add(cell);
// Add the Table Row to our Control
this.Rows.Add(tr);
// Row No 2 starts here
cell = new TableCell();
cell.Attributes["class"] = onlinecssclass;
cell.Text = "在线人员";
tr = new TableRow();
tr.Cells.Add(cell);
this.Rows.Add(tr);
// Row No 3 Starts here
cell = new TableCell();
cell.Style["Height"] = "25%";
// We create a DIV element using HtmlGenericControl object
// We can also do this using the Panel object
HtmlGenericControl d = new HtmlGenericControl("Div");
d.ID = UniqueID + "_ChatMsgs";
d.Style["Height"] = "100%";
d.Style["Width"] = "100%";
d.Style["Overflow"] = "Auto";
d.Style["Padding-Left"] = "15%";
d.ID = UniqueID + "_ChatList";
// Adding the DIV element to the Table Cell
cell.Controls.Add(d);
tr = new TableRow();
tr.Cells.Add(cell);
this.Rows.Add(tr);
Top
7 楼minghui000(沉迷网络游戏)回复于 2005-01-26 22:48:14 得分 0
// Row No 4 Starts here
cell = new TableCell();
cell.Attributes["class"] = msgcssclass;
cell.Text = "消息:";
tr = new TableRow();
tr.Cells.Add(cell);
this.Rows.Add(tr);
// Row No 5 starts here
cell = new TableCell();
cell.Style["Height"] = "35%";
d = new HtmlGenericControl("Div");
d.ID = UniqueID + "_ChatMsgs";
d.Style["Height"] = "100%";
d.Style["Width"] = "100%";
d.Style["Overflow"] = "Auto";
cell.Controls.Add(d);
tr = new TableRow();
tr.Cells.Add(cell);
this.Rows.Add(tr);
// Row No 6 Starts here
cell = new TableCell();
cell.Attributes["class"] = selusercssclass;
cell.ID = UniqueID + "_Prompt";
cell.Text = "选择一个用户:";
tr = new TableRow();
tr.Cells.Add(cell);
this.Rows.Add(tr);
// Row No 7 starts here
cell = new TableCell();
cell.Text = "<INPUT Type=\"Text\" id= '" + UniqueID + "_UserInput'> \r\n";
cell.Text += "<BR>\r\n";
cell.Text += "<Button id = '" + UniqueID + "_bnSendMsg' onclick = \"return SendMsg();\" class = " + UniqueID + "_TitleLabel style = \"display:none\"> 发送 </Button>\r\n";
cell.Text += "<Button id = '" + UniqueID + "_bnSelectName' onclick = \"return " + UniqueID + "_SelectName();\" class = " + UniqueID + "_TitleLabel style = \"display:block\"> 登陆 </Button> \r\n";
cell.Style["Color"] = "Black";
cell.Style["Background-Color"] = "Gainsboro";
tr = new TableRow();
tr.Cells.Add(cell);
this.Rows.Add(tr);
// First script Block is written into 'doc' variable
doc = "\r\n<SCRIPT FOR = 'window' EVENT = 'onload()'>";
doc += "//alert(\"done\"); \r\n";
doc += "service.use(\"";
doc += Serviceurl + "\",\"ChatWebService\"); \r\n";
doc += "" + UniqueID + "_UserInput.focus();\r\n";
doc += "</SCRIPT> \r\n";
// Then the second script block follows
doc += "<script language=\"JavaScript\">\r\n";
doc += "var " + UniqueID + "_iCallID1, " + UniqueID + "_iCallID2, " + UniqueID + "_iCallID3; \r\n";
doc += "var " + UniqueID + "_NickName; \r\n";
doc += "var " + UniqueID + "_MsgXML = new ActiveXObject(\"MSXML.DOMDocument\");\r\n";
doc += "function " + UniqueID + "_SelectName() \r\n";
doc += "{ \r\n";
doc += "if (" + UniqueID + "_UserInput.value == \"\") return false;\r\n";
doc += "" + UniqueID + "_NickName = " + UniqueID + "_UserInput.value; \r\n";
doc += "" + UniqueID + "_bnSelectName.disabled = 'true'; \r\n";
doc += "" + UniqueID + "_UserInput.disabled = 'true';\r\n";
doc += "" + UniqueID + "_iCallID1 = service.ChatWebService.call(\"Login\"," + UniqueID + "_NickName); \r\n";
doc += "} \r\n";
doc += "function " + UniqueID + "_onmyresult() \r\n";
doc += "{ \r\n";
doc += "if((event.result.error)&&(" + UniqueID + "_iCallID1==event.result.id)) \r\n";
doc += "{ \r\n";
doc += "var xfaultcode = event.result.errorDetail.code; \r\n";
doc += "var xfaultstring = event.result.errorDetail.string; \r\n";
doc += "var xfaultsoap = event.result.errorDetail.raw;\r\n";
doc += "\r\n";
doc += "// Add code to output error information here\r\n";
doc += "alert(xfaultstring);\r\n";
doc += "" + UniqueID + "_bnSelectName.disabled = false;\r\n";
doc += "" + UniqueID + "_UserInput.disabled = false; \r\n";
doc += "" + UniqueID + "_UserInput.focus();\r\n";
doc += "\r\n";
doc += "} \r\n";
doc += "else if((!event.result.error)&&(" + UniqueID + "_iCallID1==event.result.id)) \r\n";
doc += "{ \r\n";
doc += "" + UniqueID + "_ChatList.innerText= event.result.value; \r\n";
doc += "" + UniqueID + "_ChatList.scrollTop = 2000; \r\n";
doc += "" + UniqueID + "_bnSelectName.style.display = 'none';\r\n";
doc += "" + UniqueID + "_bnSendMsg.style.display = 'block';\r\n";
doc += "" + UniqueID + "_UserInput.value = \"\"; \r\n";
doc += "" + UniqueID + "_UserInput.disabled = false; \r\n";
doc += "" + UniqueID + "_UserInput.focus();\r\n";
doc += "" + UniqueID + "_Prompt.innerText = " + UniqueID + "_NickName + \" 说:\"; \r\n";
doc += "window.setTimeout('" + UniqueID + "_iCallID2 = service.ChatWebService.call(\"GetMsgs\"," + UniqueID + "_NickName);',3000); \r\n";
doc += "} \r\n";
doc += "else if((event.result.error)&&(" + UniqueID + "_iCallID2==event.result.id))\r\n";
doc += " {\r\n";
doc += "var xfaultcode = event.result.errorDetail.code; \r\n";
doc += "var xfaultstring = event.result.errorDetail.string; \r\n";
doc += "var xfaultsoap = event.result.errorDetail.raw;\r\n";
doc += "// Add code to output error information here\r\n";
doc += "alert(\"xfaultstring\");\r\n";
doc += " }\r\n";
doc += " else if((!event.result.error)&&(" + UniqueID + "_iCallID2==event.result.id))\r\n";
doc += " {\r\n";
doc += "var xmlResult = event.result.raw.xml; \r\n";
doc += " if (xmlResult != \"\" && xmlResult != null)\r\n";
doc += " {\r\n";
doc += "\r\n";
doc += "" + UniqueID + "_MsgXML.loadXML(xmlResult);\r\n";
doc += " " + UniqueID + "_ChatList.innerText = " + UniqueID + "_MsgXML.selectSingleNode(\"//UserList\").text; \r\n";
doc += "" + UniqueID + "_ChatList.scrollTop = 2000; \r\n";
doc += " " + UniqueID + "_ChatMsgs.innerHTML += " + UniqueID + "_MsgXML.selectSingleNode(\"//Messages\").text;\r\n";
doc += "" + UniqueID + "_ChatMsgs.scrollTop = 2000; \r\n";
doc += " }\r\n";
doc += " window.setTimeout('" + UniqueID + "_iCallID2 = service.ChatWebService.call(\"GetMsgs\"," + UniqueID + "_NickName);',3000);\r\n";
doc += " }\r\n";
doc += "else if((event.result.error)&&(" + UniqueID + "_iCallID3==event.result.id))\r\n";
doc += " {\r\n";
doc += "var xfaultcode = event.result.errorDetail.code; \r\n";
doc += "var xfaultstring = event.result.errorDetail.string; \r\n";
doc += "var xfaultsoap = event.result.errorDetail.raw;\r\n";
doc += "// Add code to output error information here\r\n";
doc += "alert(\"xfaultstring\");\r\n";
doc += " }\r\n";
doc += " else if((!event.result.error)&&(" + UniqueID + "_iCallID3==event.result.id))\r\n";
doc += " {\r\n";
doc += "var xmlResult = event.result.raw.xml; \r\n";
doc += " if (xmlResult != \"\" && xmlResult != null)\r\n";
doc += " {\r\n";
doc += "\r\n";
doc += "" + UniqueID + "_MsgXML.loadXML(xmlResult);\r\n";
doc += " " + UniqueID + "_ChatList.innerText = " + UniqueID + "_MsgXML.selectSingleNode(\"//UserList\").text; \r\n";
doc += " " + UniqueID + "_ChatMsgs.innerHTML += " + UniqueID + "_MsgXML.selectSingleNode(\"//Messages\").text;\r\n";
doc += " " + UniqueID + "_ChatList.scrollTop = 2000; \r\n";
doc += " " + UniqueID + "_bnSendMsg.disabled = false;\r\n";
doc += " " + UniqueID + "_ChatMsgs.scrollTop = 2000; \r\n";
doc += " " + UniqueID + "_UserInput.value = \"\";\r\n";
doc += " " + UniqueID + "_UserInput.disabled = false;\r\n";
doc += " " + UniqueID + "_UserInput.focus();\r\n";
doc += " }\r\n";
doc += " window.setTimeout('" + UniqueID + "_iCallID2 = service.ChatWebService.call(\"GetMsgs\"," + UniqueID + "_NickName);',3000);\r\n";
doc += " }\r\n";
doc += "} \r\n";
doc += "function SendMsg()\r\n";
doc += "{ \r\n";
doc += "if (" + UniqueID + "_UserInput.value == \"\") return false;\r\n";
doc += "" + UniqueID + "_bnSendMsg.disabled = 'true';\r\n";
doc += "" + UniqueID + "_UserInput.disabled = 'true';\r\n";
doc += "" + UniqueID + "_iCallID3 = service.ChatWebService.call(\"XchangeMsgs\"," + UniqueID + "_NickName," + UniqueID + "_UserInput.value);\r\n";
doc += "} \r\n";
doc += "</script> \r\n";
}
}
}
Top




