[SOLVED] Updating a Chat Client

Answered Closed
0
0

Hello,

I have a couple of apps created in VWG that I’ve been looking at porting over to WiseJ.  One of them is an IRC chat client using IRCDotNet for the back end.  In VWG I used the SignalR WebSocket extension to handle refreshing the client with new messages/nick list changes etc. once that feature was added, but I’m not sure how to do that in WiseJ since WebSocket is built right in.

I’ve messed around with the background task sample to try and implement that functionality in WiseJ, but I haven’t figured out how to adapt it to something that doesn’t require a user input like a button press to kick off the task with Application.Start.  Is there a way to call Application.Update when a new message comes in from the IRC server to make the client update?

Thanks,

Chris

  • You must to post comments
Best Answer
1
0

Hi Chris,

I attached the modified ChatWindow.vb. Look for ‘ Wisej: comments.

In short, you simply need to restore the context when you want to update the client from an out-of-bound event. That is a thread that was not started by a client event therefore not knowing anything about the session and websocket connection. Once the context is restored you can update anything on the client.

We use the “using” pattern to ensure that the thread is “cleared” when the context is not needed. It’s not necessary, but it’s good practice since Wisej internally uses [ThreadStatic] context field in order to minimize lookups.

Best,

Luca

 

Attachment
  • You must to post comments
Great Answer
0
0

Chris, I’m following up on this to tell you that the all Application.Context, Using, etc. will be removed in the next update and Application.Update() will work without all that. It’s a lot simpler…

Best,

Luca

  • You must to post comments
0
0

Hi Chris,

Is the irc service a static instance firing events, or does it take a list of subscriptions?

Can you send a sample app, wisej or vwg.

Best,

Luca

  • You must to post comments
0
0

Hey Luca,

A static instance firing events. Attached is a zip of the WiseJ test app in VB I’ve been working on.  It’s basically just a Window with an HTML box on it to display messages at this point.

On Form Load, it creates an instance of IrcDotNet client connection, which connects to the specified server (in the test app it’s Ustream’s IRC server.) On ClientRegistered, handlers are added for the user-specific events (mode/away/channel join/etc.), and it joins the user to the channel specified in the web.config. The channel join creates a ChatChannel object and attaches handlers for various channel-specific events such as receiving nick list changes.

Normally these would update the nick list grid, add labels for different channels, etc. but thus far I’ve kept it just to seeing if I can get the client to update with the any new messages in the HTML box so most of that is commented out.  I was hoping it would be as simple as tossing Application.Update in the AddMsgtoChannel sub, but that doesn’t seem to do anything. (Edit: I also tried just using a regular label to make sure it didn’t have to do with the HTML box itself.)

Thanks,
Chris

  • You must to post comments
0
0

Thanks Luca!  The solution is much appreciated and making it even simpler is always a bonus. 🙂

Any idea on ETA for that update? I can always work with Context and then remove it later if it’s not in the immediate future.

  • You must to post comments
0
0

Tonight or tomorrow.

  • You must to post comments
0
0

By the way… a very simple chat application is available in our sample code section:
https://wisej.com/examples/

  • You must to post comments
Showing 7 results