nettcpbinding - How can I provide server-side administrative control of WCF clients? -
i have wcf, tcp-based client server application (self-hosted) in communication occurs via callbacks , instancecontextmode persession. want provide admin interface app allow administrator view details of connected users , provide degree of administrative control (for example forcibly disconnecting session).
since i'm using callbacks, each client proxy gives server instance context via constructor. example, client instantiates proxy server using:
public class clientcallbackhandler : imyservercallback { proxy = new myserviceclient(new instancecontext(this));
at server side retrieve context using:
var currencontext = operationcontext.current;
my initial thoughts implement singleton 'sessionadmin' class maintains collection of operationcontext objects (i.e. - holds reference context of each connected client). every new client session register same instance of 'sessionadmin' class, thereby providing central class has access client sessions.
this works degree, @ various points when access collection of 'operationcontext' objects clients details or perform other operation notice context throwing 'object disposed' exceptions.
my question firstly, above sound reasonable way of providing server-side administrative control on wcf sessions? if so, how can maintain collection of client sessions or contexts on server-side without objects being disposed? example of problem is:
foreach(var context in mycontextcollection) { displayclientdetails(context); ... } public void displayclientdetails(operationcontext context) { var sessionid = context.sessionid; //no problem here var user = context.servicesecuritycontext.primaryidentity.name; //servicesecuritycontext has been disposed
Comments
Post a Comment