e.Context.User.Identity.Name? capturing in <WebSyncEvent(EventType.AfterConnect)> event

64 views
Skip to first unread message

george.n...@hotmail.com

unread,
Mar 26, 2013, 6:13:20 AM3/26/13
to web...@googlegroups.com
In your documentation link: http://docs.frozenmountain.com/websync4/#class=websync-code-snippets-binding-data
 
you give an example how to capture the e.Context.User.Identity.Name in the  <WebSyncEvent(EventType.AfterConnect)> event.

However, there is nowhere from the client side to set this property before connecting to the server. The AfterConnect event fires immediately after the BeforeConnect event where the passed arguments from the client side cannot reference the context.user.identinity namespace.

So I am wondering what is the appropriate step to set up the User.Identity.Name when the client calls the server to connect?

Regards,

George

george.n...@hotmail.com

unread,
Mar 26, 2013, 6:31:28 AM3/26/13
to web...@googlegroups.com
n.b. example cited above relates to a connection from a desktop client, so no other client authentication is taking place in the web server.

george.n...@hotmail.com

unread,
Mar 26, 2013, 6:39:23 AM3/26/13
to web...@googlegroups.com
so, if the user if subscribing from a desktop application, with no further web authentication from the server available, it seems you cannot use the notify method 

1// in a WebSync server event - "e" is the WebSyncEventArgs object
2WebSyncServer.Notify(e.Client.ClientId, Json.Serialize("Hello, this is WebSync."));

the client.clientId is simply not available. How you can work around this?

On Tuesday, March 26, 2013 12:13:20 PM UTC+2, george.n...@hotmail.com wrote:

george.n...@hotmail.com

unread,
Mar 26, 2013, 7:21:45 AM3/26/13
to web...@googlegroups.com
well, found an interim solution as follows:

(a) on the client side create a  metajson with client credentials and pass it on to the connect arguments.

(b) on the server side on the BeforeConnect event retrieve the metajason and check connected clients bindings if they contain same client credentials as the client attempting to connect. This way a single client cannot connect twice.

(c) on the server side on the afterconnect event bind the client credentials to the specific client.

I am assuming that if the server detects a client disconnect will remove the user for the connected clients list, is this correct?





On Tuesday, March 26, 2013 12:13:20 PM UTC+2, george.n...@hotmail.com wrote:

Jerod Venema

unread,
Mar 26, 2013, 9:18:52 AM3/26/13
to web...@googlegroups.com
Regarding this: "e.Context.User.Identity.Name....nowhere from the client side to set this property before connecting to the server."

The reason you can't do that is this is a standard .NET property. You don't set it on the client explicitly, it's set automatically for you by .NET by virtue of the fact that you have some sort of authentication token. Here's an example of how to do so from a WinForms app:


You'll note that you still do the login, and then set the authentication cookie token with each subsequent WebSync request.

Regarding MetaJson - you can do exactly as you described. It's a completely legit alternate solution.

Finally, yep, the server will detect and fire the disconnect event on the server-side when the clients idle out.

--
You received this message because you are subscribed to the Google Groups "WebSync" group.
To unsubscribe from this group and stop receiving emails from it, send an email to websync+u...@googlegroups.com.
To post to this group, send email to web...@googlegroups.com.
Visit this group at http://groups.google.com/group/websync?hl=en.
To view this discussion on the web visit https://groups.google.com/d/msg/websync/-/q_al--OPT4UJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jerod Venema
Frozen Mountain Software
919-300-5141 (United States)
604-227-2453 (Canada)
888-379-6686 (Extension 101)
Reply all
Reply to author
Forward
0 new messages