K
Kevin Gibbons
Hi,
I have written a chat application to write new messages collected from
a web service to the screen, however I am having problems adding the
messages to the last received messages.
At the moment only new messages are being displayed. I'm sure that
this shouldn't be too difficult but would be grateful for some help.
I've attached the javascript and html to get the new messages:
<%@ Page language="c#" Codebehind="MessageWindow.aspx.cs"
AutoEventWireup="false" Inherits="Chat.Chat.MessageWindow" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<script language="javascript">
var iCallID;
var lastmessage = "";
var newmessage = "";
function init()
{
service.useService("http://localhost/chat/chat/messages/instantmessages.asmx?WSDL","InstantMessages");
setInterval( "GetNewMessages()", 100 )
}
function GetNewMessages()
{
GetLastMessage();
iCallID = service.InstantMessages.callService( "GetMessages" );
}
function onWSresult()
{
if((event.result.error)&&(iCallID==event.result.id))
{
var xfaultcode = event.result.errorDetail.code;
var xfaultstring = event.result.errorDetail.string;
var xfaultsoap = event.result.errorDetail.raw;
document.writeln("ERROR. Method call failed!");
document.writeln("Call ID:" + iCallID);
document.writeln("Fault Code:" + xfaultcode);
document.writeln("Fault String:" + xfaultstring);
document.writeln("SOAP Data:" + xfaultsoap);
}
else if(event.result.error == false)
{
newmessages.innerText = newmessages.value + event.result.value;
}
}
function GetLastMessage()
{
oldmessages.innerText = oldmessages.value + newmessages.value;
}
</script>
<html>
<head>
<title>MessageWindow</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body onload="init()">
<div id="service" style="behavior:url(webservice.htc)"
onresult="onWSresult()"></div>
<form runat="server">
<span id="oldmessages"></span>
<span id="newmessages"></span>
</form>
</body>
</html>
Thanks in advance,
Kevin
I have written a chat application to write new messages collected from
a web service to the screen, however I am having problems adding the
messages to the last received messages.
At the moment only new messages are being displayed. I'm sure that
this shouldn't be too difficult but would be grateful for some help.
I've attached the javascript and html to get the new messages:
<%@ Page language="c#" Codebehind="MessageWindow.aspx.cs"
AutoEventWireup="false" Inherits="Chat.Chat.MessageWindow" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<script language="javascript">
var iCallID;
var lastmessage = "";
var newmessage = "";
function init()
{
service.useService("http://localhost/chat/chat/messages/instantmessages.asmx?WSDL","InstantMessages");
setInterval( "GetNewMessages()", 100 )
}
function GetNewMessages()
{
GetLastMessage();
iCallID = service.InstantMessages.callService( "GetMessages" );
}
function onWSresult()
{
if((event.result.error)&&(iCallID==event.result.id))
{
var xfaultcode = event.result.errorDetail.code;
var xfaultstring = event.result.errorDetail.string;
var xfaultsoap = event.result.errorDetail.raw;
document.writeln("ERROR. Method call failed!");
document.writeln("Call ID:" + iCallID);
document.writeln("Fault Code:" + xfaultcode);
document.writeln("Fault String:" + xfaultstring);
document.writeln("SOAP Data:" + xfaultsoap);
}
else if(event.result.error == false)
{
newmessages.innerText = newmessages.value + event.result.value;
}
}
function GetLastMessage()
{
oldmessages.innerText = oldmessages.value + newmessages.value;
}
</script>
<html>
<head>
<title>MessageWindow</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body onload="init()">
<div id="service" style="behavior:url(webservice.htc)"
onresult="onWSresult()"></div>
<form runat="server">
<span id="oldmessages"></span>
<span id="newmessages"></span>
</form>
</body>
</html>
Thanks in advance,
Kevin