Home All Groups Group Topic Archive Search About

Have WCF Callback notify a single client ?

Author
26 Nov 2007 9:54 PM
aiKeith
Hello,

Was wondering how or if this is possible - assuming the use of FullDuplex,
but open to whatever works well.

Goal:
Have x number of clients subscribe to a WCF fullduplex over tcp service --
lets say they subscribe to: 

DoIhaveMail()

On the server side, lets say we have an object that is alerted when a sql
table gets a new row, this object then invokes the IHaveMailOccured Event --

If this new row added to the table was mail for user b, how do i callback
only user b to say 'you have mail.' ?

I have read about Publish/Subscribe using Callbacks, streams and MSMQ -- but
its as tho the server alerts all clients who subscribed to that channel.

Thanks in advance :-)

Author
27 Nov 2007 8:27 AM
Dominick Baier
Hi,

sure -

you either use the duplex support in WCF to store the CallbackChannels internally
and call back through them whenever an event occurs.

Or have your own infrastructure where the client news up a ServiceHost and
you pass a callback URI to the service for later notification.


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

Show quote
> Hello,
>
> Was wondering how or if this is possible - assuming the use of
> FullDuplex, but open to whatever works well.
>
> Goal:
> Have x number of clients subscribe to a WCF fullduplex over tcp
> service --
> lets say they subscribe to:
> DoIhaveMail()
>
> On the server side, lets say we have an object that is alerted when a
> sql table gets a new row, this object then invokes the
> IHaveMailOccured Event --
>
> If this new row added to the table was mail for user b, how do i
> callback only user b to say 'you have mail.' ?
>
> I have read about Publish/Subscribe using Callbacks, streams and MSMQ
> -- but its as tho the server alerts all clients who subscribed to that
> channel.
>
> Thanks in advance :-)
>
Author
27 Nov 2007 6:11 PM
aiKeith
Hello Dominick, thank you so much for your response.

Questions tho:

" you either use the duplex support in WCF to store the CallbackChannels
internally  and call back through them whenever an event occurs."

If we have a callback that users subscribe to, how do we alert only a
particular client named 'flappy' that has subscribed to the callback?

"Or have your own infrastructure where the client news up a ServiceHost and
you pass a callback URI to the service for later notification."

Im still missing the part of how to raise the event for only a specific user
- or am i thinking too hard? ie:

For instance if 3 users subscribed to the event SomethingHappened();
How can i say raise the event SomethingHappened() only for user number 2?

For some reason im having a hard time grasping how this would actually work.

Thanks again for your comments, i hope to hear more :-)



Show quote
"Dominick Baier" wrote:

> Hi,
>
> sure -
>
> you either use the duplex support in WCF to store the CallbackChannels internally
> and call back through them whenever an event occurs.
>
> Or have your own infrastructure where the client news up a ServiceHost and
> you pass a callback URI to the service for later notification.
>
>
> -----
> Dominick Baier (http://www.leastprivilege.com)
>
> Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
>
> > Hello,
> >
> > Was wondering how or if this is possible - assuming the use of
> > FullDuplex, but open to whatever works well.
> >
> > Goal:
> > Have x number of clients subscribe to a WCF fullduplex over tcp
> > service --
> > lets say they subscribe to:
> > DoIhaveMail()
> >
> > On the server side, lets say we have an object that is alerted when a
> > sql table gets a new row, this object then invokes the
> > IHaveMailOccured Event --
> >
> > If this new row added to the table was mail for user b, how do i
> > callback only user b to say 'you have mail.' ?
> >
> > I have read about Publish/Subscribe using Callbacks, streams and MSMQ
> > -- but its as tho the server alerts all clients who subscribed to that
> > channel.
> >
> > Thanks in advance :-)
> >
>
>
>
Author
27 Nov 2007 7:30 PM
Dominick Baier
how about storing the callback reference in a dictionary<string, channel>
that maps the user to a callback channel?


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

Show quote
> Hello Dominick, thank you so much for your response.
>
> Questions tho:
>
> " you either use the duplex support in WCF to store the
> CallbackChannels internally  and call back through them whenever an
> event occurs."
>
> If we have a callback that users subscribe to, how do we alert only a
> particular client named 'flappy' that has subscribed to the callback?
>
> "Or have your own infrastructure where the client news up a
> ServiceHost and you pass a callback URI to the service for later
> notification."
>
> Im still missing the part of how to raise the event for only a
> specific user - or am i thinking too hard? ie:
>
> For instance if 3 users subscribed to the event SomethingHappened();
> How can i say raise the event SomethingHappened() only for user number
> 2?
>
> For some reason im having a hard time grasping how this would actually
> work.
>
> Thanks again for your comments, i hope to hear more :-)
>
> "Dominick Baier" wrote:
>
>> Hi,
>>
>> sure -
>>
>> you either use the duplex support in WCF to store the
>> CallbackChannels internally and call back through them whenever an
>> event occurs.
>>
>> Or have your own infrastructure where the client news up a
>> ServiceHost and you pass a callback URI to the service for later
>> notification.
>>
>> -----
>> Dominick Baier (http://www.leastprivilege.com)
>> Developing More Secure Microsoft ASP.NET 2.0 Applications
>> (http://www.microsoft.com/mspress/books/9989.asp)
>>
>>> Hello,
>>>
>>> Was wondering how or if this is possible - assuming the use of
>>> FullDuplex, but open to whatever works well.
>>>
>>> Goal:
>>> Have x number of clients subscribe to a WCF fullduplex over tcp
>>> service --
>>> lets say they subscribe to:
>>> DoIhaveMail()
>>> On the server side, lets say we have an object that is alerted when
>>> a sql table gets a new row, this object then invokes the
>>> IHaveMailOccured Event --
>>>
>>> If this new row added to the table was mail for user b, how do i
>>> callback only user b to say 'you have mail.' ?
>>>
>>> I have read about Publish/Subscribe using Callbacks, streams and
>>> MSMQ -- but its as tho the server alerts all clients who subscribed
>>> to that channel.
>>>
>>> Thanks in advance :-)
>>>
Author
27 Nov 2007 8:25 PM
aiKeith
OK, this may be the part i was missing.  So each CallBackChannel is specific
to only one user?

Show quote
:-)



"Dominick Baier" wrote:

> how about storing the callback reference in a dictionary<string, channel>
> that maps the user to a callback channel?
>
>
> -----
> Dominick Baier (http://www.leastprivilege.com)
>
> Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
>
> > Hello Dominick, thank you so much for your response.
> >
> > Questions tho:
> >
> > " you either use the duplex support in WCF to store the
> > CallbackChannels internally  and call back through them whenever an
> > event occurs."
> >
> > If we have a callback that users subscribe to, how do we alert only a
> > particular client named 'flappy' that has subscribed to the callback?
> >
> > "Or have your own infrastructure where the client news up a
> > ServiceHost and you pass a callback URI to the service for later
> > notification."
> >
> > Im still missing the part of how to raise the event for only a
> > specific user - or am i thinking too hard? ie:
> >
> > For instance if 3 users subscribed to the event SomethingHappened();
> > How can i say raise the event SomethingHappened() only for user number
> > 2?
> >
> > For some reason im having a hard time grasping how this would actually
> > work.
> >
> > Thanks again for your comments, i hope to hear more :-)
> >
> > "Dominick Baier" wrote:
> >
> >> Hi,
> >>
> >> sure -
> >>
> >> you either use the duplex support in WCF to store the
> >> CallbackChannels internally and call back through them whenever an
> >> event occurs.
> >>
> >> Or have your own infrastructure where the client news up a
> >> ServiceHost and you pass a callback URI to the service for later
> >> notification.
> >>
> >> -----
> >> Dominick Baier (http://www.leastprivilege.com)
> >> Developing More Secure Microsoft ASP.NET 2.0 Applications
> >> (http://www.microsoft.com/mspress/books/9989.asp)
> >>
> >>> Hello,
> >>>
> >>> Was wondering how or if this is possible - assuming the use of
> >>> FullDuplex, but open to whatever works well.
> >>>
> >>> Goal:
> >>> Have x number of clients subscribe to a WCF fullduplex over tcp
> >>> service --
> >>> lets say they subscribe to:
> >>> DoIhaveMail()
> >>> On the server side, lets say we have an object that is alerted when
> >>> a sql table gets a new row, this object then invokes the
> >>> IHaveMailOccured Event --
> >>>
> >>> If this new row added to the table was mail for user b, how do i
> >>> callback only user b to say 'you have mail.' ?
> >>>
> >>> I have read about Publish/Subscribe using Callbacks, streams and
> >>> MSMQ -- but its as tho the server alerts all clients who subscribed
> >>> to that channel.
> >>>
> >>> Thanks in advance :-)
> >>>
>
>
>
Author
27 Nov 2007 8:41 PM
Dominick Baier
yep ;)
-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

Show quote
> OK, this may be the part i was missing.  So each CallBackChannel is
> specific to only one user?
>
> :-)
>
> "Dominick Baier" wrote:
>
>> how about storing the callback reference in a dictionary<string,
>> channel> that maps the user to a callback channel?
>>
>> -----
>> Dominick Baier (http://www.leastprivilege.com)
>> Developing More Secure Microsoft ASP.NET 2.0 Applications
>> (http://www.microsoft.com/mspress/books/9989.asp)
>>
>>> Hello Dominick, thank you so much for your response.
>>>
>>> Questions tho:
>>>
>>> " you either use the duplex support in WCF to store the
>>> CallbackChannels internally  and call back through them whenever an
>>> event occurs."
>>>
>>> If we have a callback that users subscribe to, how do we alert only
>>> a particular client named 'flappy' that has subscribed to the
>>> callback?
>>>
>>> "Or have your own infrastructure where the client news up a
>>> ServiceHost and you pass a callback URI to the service for later
>>> notification."
>>>
>>> Im still missing the part of how to raise the event for only a
>>> specific user - or am i thinking too hard? ie:
>>>
>>> For instance if 3 users subscribed to the event SomethingHappened();
>>> How can i say raise the event SomethingHappened() only for user
>>> number 2?
>>>
>>> For some reason im having a hard time grasping how this would
>>> actually work.
>>>
>>> Thanks again for your comments, i hope to hear more :-)
>>>
>>> "Dominick Baier" wrote:
>>>
>>>> Hi,
>>>>
>>>> sure -
>>>>
>>>> you either use the duplex support in WCF to store the
>>>> CallbackChannels internally and call back through them whenever an
>>>> event occurs.
>>>>
>>>> Or have your own infrastructure where the client news up a
>>>> ServiceHost and you pass a callback URI to the service for later
>>>> notification.
>>>>
>>>> -----
>>>> Dominick Baier (http://www.leastprivilege.com)
>>>> Developing More Secure Microsoft ASP.NET 2.0 Applications
>>>> (http://www.microsoft.com/mspress/books/9989.asp)
>>>>> Hello,
>>>>>
>>>>> Was wondering how or if this is possible - assuming the use of
>>>>> FullDuplex, but open to whatever works well.
>>>>>
>>>>> Goal:
>>>>> Have x number of clients subscribe to a WCF fullduplex over tcp
>>>>> service --
>>>>> lets say they subscribe to:
>>>>> DoIhaveMail()
>>>>> On the server side, lets say we have an object that is alerted
>>>>> when
>>>>> a sql table gets a new row, this object then invokes the
>>>>> IHaveMailOccured Event --
>>>>> If this new row added to the table was mail for user b, how do i
>>>>> callback only user b to say 'you have mail.' ?
>>>>>
>>>>> I have read about Publish/Subscribe using Callbacks, streams and
>>>>> MSMQ -- but its as tho the server alerts all clients who
>>>>> subscribed to that channel.
>>>>>
>>>>> Thanks in advance :-)
>>>>>
Author
27 Nov 2007 10:56 PM
aiKeith
Thanks for sticking with me.  It all makes sense now, especially after
creating a complete working version - the piece i was completely missing was:

<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession,
ConcurrencyMode:=ConcurrencyMode.Multiple)> _

The PerSession makes sense, i was assuming it was always a singleton, thus
all clients were using the same 'instance' of the object - obv. not so with
PerSession.

Thanks again for your help.  Have a great one !!!



Show quote
"Dominick Baier" wrote:

> yep ;)
> -----
> Dominick Baier (http://www.leastprivilege.com)
>
> Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
>
> > OK, this may be the part i was missing.  So each CallBackChannel is
> > specific to only one user?
> >
> > :-)
> >
> > "Dominick Baier" wrote:
> >
> >> how about storing the callback reference in a dictionary<string,
> >> channel> that maps the user to a callback channel?
> >>
> >> -----
> >> Dominick Baier (http://www.leastprivilege.com)
> >> Developing More Secure Microsoft ASP.NET 2.0 Applications
> >> (http://www.microsoft.com/mspress/books/9989.asp)
> >>
> >>> Hello Dominick, thank you so much for your response.
> >>>
> >>> Questions tho:
> >>>
> >>> " you either use the duplex support in WCF to store the
> >>> CallbackChannels internally  and call back through them whenever an
> >>> event occurs."
> >>>
> >>> If we have a callback that users subscribe to, how do we alert only
> >>> a particular client named 'flappy' that has subscribed to the
> >>> callback?
> >>>
> >>> "Or have your own infrastructure where the client news up a
> >>> ServiceHost and you pass a callback URI to the service for later
> >>> notification."
> >>>
> >>> Im still missing the part of how to raise the event for only a
> >>> specific user - or am i thinking too hard? ie:
> >>>
> >>> For instance if 3 users subscribed to the event SomethingHappened();
> >>> How can i say raise the event SomethingHappened() only for user
> >>> number 2?
> >>>
> >>> For some reason im having a hard time grasping how this would
> >>> actually work.
> >>>
> >>> Thanks again for your comments, i hope to hear more :-)
> >>>
> >>> "Dominick Baier" wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> sure -
> >>>>
> >>>> you either use the duplex support in WCF to store the
> >>>> CallbackChannels internally and call back through them whenever an
> >>>> event occurs.
> >>>>
> >>>> Or have your own infrastructure where the client news up a
> >>>> ServiceHost and you pass a callback URI to the service for later
> >>>> notification.
> >>>>
> >>>> -----
> >>>> Dominick Baier (http://www.leastprivilege.com)
> >>>> Developing More Secure Microsoft ASP.NET 2.0 Applications
> >>>> (http://www.microsoft.com/mspress/books/9989.asp)
> >>>>> Hello,
> >>>>>
> >>>>> Was wondering how or if this is possible - assuming the use of
> >>>>> FullDuplex, but open to whatever works well.
> >>>>>
> >>>>> Goal:
> >>>>> Have x number of clients subscribe to a WCF fullduplex over tcp
> >>>>> service --
> >>>>> lets say they subscribe to:
> >>>>> DoIhaveMail()
> >>>>> On the server side, lets say we have an object that is alerted
> >>>>> when
> >>>>> a sql table gets a new row, this object then invokes the
> >>>>> IHaveMailOccured Event --
> >>>>> If this new row added to the table was mail for user b, how do i
> >>>>> callback only user b to say 'you have mail.' ?
> >>>>>
> >>>>> I have read about Publish/Subscribe using Callbacks, streams and
> >>>>> MSMQ -- but its as tho the server alerts all clients who
> >>>>> subscribed to that channel.
> >>>>>
> >>>>> Thanks in advance :-)
> >>>>>
>
>
>

AddThis Social Bookmark Button