Remoting

  • Thread starter Charles A. Lackman
  • Start date
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
 
B

bruce barker

your approach will not work with web forms. for each page request a form
object is created, called to produce the html then released. if the browser
requests another page the cycle starts over.

once the html has been render, whatever your class does to events it
recieves has no impact on the browser (as its already has the html). to do a
web based chat you need to have the webpage poll the server for messages.
most sites do this with a javascritp and a hidden iframe.

-- bruce (sqlwork.com)



| 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
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top