Print Page | Close Window

Push feature on Winforms

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2924
Printed Date: 13-May-2026 at 3:07pm


Topic: Push feature on Winforms
Posted By: wackywhizz
Subject: Push feature on Winforms
Date Posted: 25-Aug-2011 at 3:14am
I've seen samples and codes about the PUSH feature but they're just on WPF and SL. Is it just because there are just no samples available for Winforms or is it that this PUSH feature is not available on Winforms?



Replies:
Posted By: sbelini
Date Posted: 25-Aug-2011 at 9:42am
Hi wackywhizz,

Although there isn't an specific Winforms sample using Push notification, the concept is the same and you should be able to implement it in a Winforms app.

Silvio.


Posted By: wackywhizz
Date Posted: 25-Aug-2011 at 4:57pm
Hi Silvio,

Can you point me to the right direction as to how do I start trying this feature out..? I have copies of both sample codes for Silverlight and WPF but I was thinking of creating a win app from scratch? Would you recommend me to use some of the existing projects from the sample code I downloaded?

Thanks,
Lawrence


Posted By: sbelini
Date Posted: 25-Aug-2011 at 5:21pm
Hi Lawrence,
 
You could use the DomainModel project if you are simply trying to create a sample using NorthwindIB.
 
If you take a closer look, the push notification feature is very much alike in both SL and WPF samples.
 
Basically, all you need is:
1- Define a push service; (i.e. use [AllowRpc] and method signature conforming to ServerNotifyDelegate)
2- Subscribe to it; (RegisterCallback method)
3- Configure it. (in the server and client config files)
 
You will find detailed information about the Push notification in the http://drc.ideablade.com/xwiki/bin/view/Documentation/push-notification - DevForce Resource Center .
 
Silvio.


Posted By: wackywhizz
Date Posted: 07-Sep-2011 at 3:24am
Hi Silvio,

I read the documents and also downloaded the SL sample code for the push service. I then tried to create a winform counterpart and I'm having a "Exception has been thrown by the target of an invocation" error. Can you help me with this..?

Here is my project file:  http://dl.dropbox.com/u/40770720/WinFormsPush.rar - http://dl.dropbox.com/u/40770720/WinFormsPush.rar
Here is a screenshot of my error:  http://dl.dropbox.com/u/40770720/exception.png - http://dl.dropbox.com/u/40770720/exception.png

Thanks,
Lawrence


Posted By: sbelini
Date Posted: 08-Sep-2011 at 5:26pm
Hi Lawrence,

I'm taking a look at your project and will follow up shortly.

Silvio.


Posted By: sbelini
Date Posted: 08-Sep-2011 at 6:59pm
Lawrence,

The issue is that the method signature does not conform to the ServerNotifyDelegate.

You have:

  [AllowRpc]
  public static void NewMessage(Guid key, INotificationManager mMgr, DAL.DFModel eMgr)

but you should have instead:

  [AllowRpc]
  public static void NewMessage(Guid key, INotificationManager mMgr, EntityManager eMgr)


You can later create a sub-typed entity manager:

  entityMgr = new DFModel(eMgr);


Also, be sure to enable the notificationService in the server (i.e. web.config file):

<notificationService enabled="true" />


Regards,
   Silvio.


Posted By: wackywhizz
Date Posted: 08-Sep-2011 at 7:39pm
Hi Silvio,

I already have the notification service enabled and I did what you said about using the correct signature of the ServerNotifyDelegate, but I still experience the exception has been thrown error.. Is there maybe any additional assemblies that I need to add into my project?

Thanks,
Lawrence


Posted By: sbelini
Date Posted: 09-Sep-2011 at 8:58am
Hi Lawrence,

I haven't added any additional assemblies.

I'm sending your sample back with the changes I made, so you can take a closer look. (note that I changed the connection string to match my datasource)

You can download it at  uploads/892/WinFormsPush.zip - uploads/892/WinFormsPush.zip

Regards,
   Silvio.


Posted By: wackywhizz
Date Posted: 14-Nov-2011 at 2:12am
Hi Silvio,

I'm still receiving the errors. I've attached a new one I created trying to fix it by creating an all new project. Still I seem to get the same error. I've attached the project together with a screenshot of the exception I've been experiencing.



uploads/1247/PushServerClient.rar - uploads/1247/PushServerClient.rar

Thanks,
Lawrence


Posted By: sbelini
Date Posted: 14-Nov-2011 at 8:57am
Thanks Lawrence,

I'm taking a look at you sample and will follow up shortly.

Silvio.


Posted By: kimj
Date Posted: 14-Nov-2011 at 3:22pm

Hi Lawrence,

To use Push in DevForce you do have to tell the server that you want it, so that it sets up the appropriate endpoint(s) to listen on. You can do this by adding one simple setting within the ideablade.configuration section of the web.config:

  <notificationService enabled="true" />

This is sufficient to allow DevForce to set up the Push service with all defaults in place.

On the client side in a WinClient application you also have to provide the client-side port which will be "listening" for messages from the server.  You do this in your app.config as follows (port 9012 is just used as an example):

  <notificationService clientPort="9012" />

The http://drc.ideablade.com/xwiki/bin/view/Documentation/code-sample-push-notification - WPF sample shows this configuration and you can find out more http://drc.ideablade.com/xwiki/bin/view/Documentation/push-notification#HConfigurethepushservice - here .

 




Print Page | Close Window