C
Charles A. Lackman
Hello,
I have created a chat (from a remoting book 'Advanced .NET Remoting in
VB.NET') that runs great in a desktop application. I have taken the code
and converted it over to an aspx web page. When the message is sent to the
server the aspx page waits for the message to return and then places it
inside a listbox.
The problem is that when another visitor sends a message no event is fired
that causes the other visitors to receive the message, or the page is not
listening.
I have done some experiments and have found that if one visitor sends a
message over and over really fast and another visitor sends a single
message, that if the timing is right he will receive the other visitors
message.
What could I be doing wrong. My code example is below.
Dim bcaster As IBroadcaster
Dim WithEvents wrapper As BroadcastEventWrapper
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Session("Done") = Nothing Then
Try
RemotingConfiguration.Configure(Server.MapPath("XMLConfig.xml"))
Catch exc As Exception
End Try
ListBox1.Items.Add("Welcome...")
Session("Done") = "True"
End If
bcaster = CType(RemotingHelper.GetObject(GetType(IBroadcaster)),
IBroadcaster)
wrapper = New BroadcastEventWrapper(bcaster)
End Sub
Public Sub wrapper_MessageArrivedLocally(ByVal msg As String) _
Handles wrapper.MessageArrivedLocally
ListBox1.Items.Add("Message: " & msg)
End Sub
Private Sub btnSendMessage_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSendMessage.Click
bcaster = CType(RemotingHelper.GetObject(GetType(IBroadcaster)),
IBroadcaster)
bcaster.BroadcastMessage(TextBox1.Text)
TextBox1.Text = ""
bcaster = CType(RemotingHelper.GetObject(GetType(IBroadcaster)),
IBroadcaster)
wrapper = New BroadcastEventWrapper(bcaster)
End Sub
Thanks,
Chuck
I have created a chat (from a remoting book 'Advanced .NET Remoting in
VB.NET') that runs great in a desktop application. I have taken the code
and converted it over to an aspx web page. When the message is sent to the
server the aspx page waits for the message to return and then places it
inside a listbox.
The problem is that when another visitor sends a message no event is fired
that causes the other visitors to receive the message, or the page is not
listening.
I have done some experiments and have found that if one visitor sends a
message over and over really fast and another visitor sends a single
message, that if the timing is right he will receive the other visitors
message.
What could I be doing wrong. My code example is below.
Dim bcaster As IBroadcaster
Dim WithEvents wrapper As BroadcastEventWrapper
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Session("Done") = Nothing Then
Try
RemotingConfiguration.Configure(Server.MapPath("XMLConfig.xml"))
Catch exc As Exception
End Try
ListBox1.Items.Add("Welcome...")
Session("Done") = "True"
End If
bcaster = CType(RemotingHelper.GetObject(GetType(IBroadcaster)),
IBroadcaster)
wrapper = New BroadcastEventWrapper(bcaster)
End Sub
Public Sub wrapper_MessageArrivedLocally(ByVal msg As String) _
Handles wrapper.MessageArrivedLocally
ListBox1.Items.Add("Message: " & msg)
End Sub
Private Sub btnSendMessage_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSendMessage.Click
bcaster = CType(RemotingHelper.GetObject(GetType(IBroadcaster)),
IBroadcaster)
bcaster.BroadcastMessage(TextBox1.Text)
TextBox1.Text = ""
bcaster = CType(RemotingHelper.GetObject(GetType(IBroadcaster)),
IBroadcaster)
wrapper = New BroadcastEventWrapper(bcaster)
End Sub
Thanks,
Chuck