//Check if the client is already on the client list, if not - add it public void checkIfRegistered() { IClientCallbackInterface callback = OperationContext.Current.GetCallbackChannel <IClientCallbackInterface>(); if (!clients.Contains(callback)) { clients.Add(callback); } }
/* * The implementation of the IServerInterface * */ #region Service contracts implementation /* * Populate the newly connected client with any existing data on the Simulation * */ public void populateClient() { try { //Check the client registration checkIfRegistered(); //Instantiate the callback using the current channel IClientCallbackInterface callback = OperationContext.Current.GetCallbackChannel <IClientCallbackInterface>(); //Call back towards the client with the reply callback.notifyNewScenario(mainScenario); } catch (Exception e) { //Catch and report the exception debugMessage("Failed to populate the client", e); throw new Exception("ATMS-MainSimulation-0001: Failed to populate the client."); } }