c# - Keeping track number of connected users to WCF service? -
I have pure TCP PerSession WCF service, the number of connected users (active customers) using my current argument for keeping track Service maker and heart beat mechanism
Producer I just add to a stationary member, and during raises one of these exceptions are sending heartbeat (TimeoutException, FaultException, CommunicationObjectAbortedException) for the client I number decreases.
Besides, I am using heartbeat to send other goods. So far it works perfectly, but is there any better way?
You can create your implementation, after the new instance contact is ready will be notified.
public class MyInstanceContextInitializer: IInstanceContextInitializer {public void start (InstanceContext instanceContext, message) {events hook // for example up to be notified about changes in the state of reference. // Remember refernce to it}}
and attach it
public class InstanceInitializerBehavior: IEndpointBehavior {public void AddBindingParameters (ServiceEndpoint serviceEndpoint, BindingParameterCollection bindingParameters) {} // = new MyInstanceContextInitializer EndpointDispatcher.DispatchRuntime public void ApplyDispatchBehavior (serviceEndpoint serviceEndpoint, endpointDispatcher endpointDispatcher) {MyInstanceContextInitializer apply custom IInstanceContextProvider to expand (); EndpointDispatcher.DispatchRuntime.InstanceContextInitializers.Add (extension); } Public void ApplyClientBehavior (ServiceEndpoint serviceEndpoint, ClientRuntime behavior) {} public void validate (ServiceEndpoint endpoint) {}}
Once you can use to get IncomingChannels property sessionful channels You can use that service to come for example.
Comments
Post a Comment