I am trying to create a “chat” like capability. As the system admin, I would like to reach out to my users via a “chat dialog”.
Here’s what I am trying (unsuccessfully).
In my app I created
A WebDialog called chatdialog with properties chatmessage As String
A method that I placed in Session called DeliverMessage(chatmessage). This method does the following…
Dim cd as New chatdialog
cd.chatmessage = chatmessage
cd.show
From my app’s admin login, I can identify all the user sessions that are active - so I find a user session and get its id and address. And I try to do this…
Dim s As App.Session // I need to declare it as app.session rather than websession so the compiler knows what s.DeliverMessage is
s = App.SessionWithIdentifier(targetid,targetaddress)
s.DeliverMessage(chatmessage)
This all works, except when I send a message from the admin account, the chat window shows up to me (the admin), not at my user’s browser as I would like.
What am I doing wrong or what is a better way to do this?
Oh - and I know that I can invoke a MsgBox to other sessions - that I have already done. But I would like to use my own dialog to enable 2-way communication between me (admin) and a user in another session.
OK - now I completely understand how the example works - so here is the difference between that, and what I am trying to accomplish. I can force myself to do it the example way, but looking for something more elegant (and useful).
Example way: retain references to MainPages so chat dialog can interact with users that are on the MainPage. Desired way: use a Method (call it Session.ChatMethod) in the local session to spawn a chat dialog - this way the user can be on any page and receive a chat. Then the Admin from his session can find the user’s ‘remote’ session and invoke the Session.ChatMethod to communicate with the user of the remote session.
When I do this, so far, the ChatMethod spawns the ChatDialog in the Admin session rather than in the remote session - I can’t figure out why that doesn’t work. Any insights?
To emphasize the point, here is an observation…
When Session.ChatMethod contains this code: MsgBox “Can you chat?”
The message is delivered to the remote user. (but the user can not respond via a MsgBox)
When Session.ChatMethod contains this code: Self.ChatDial = New ChatDialog
Self.ChatDial.Label1.Text = m
Self.ChatDial.Show
The message is delivered to myself, rather than to the remote user.