[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] public class MyService : IMyService { #region Feilds private static object syncObj = new object(); private static Dictionary<IContextChannel, string> _users = new Dictionary<IContextChannel, string>(); #endregion #region Properties public IContextChannel CurrentUserChannel { get { return OperationContext.Current.Channel; } } public string CurrentUserName { get { return OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Name; } } #endregion #region IMyService Members public void Connect() { lock (syncObj) { if (_users.ContainsValue(CurrentUserName)) { _users.Remove(CurrentUserChannel); } _users.Add(CurrentUserChannel, CurrentUserName); } CurrentUserChannel.Faulted += new EventHandler(CurrentUserChannel_Faulted); CurrentUserChannel.Closing += new EventHandler(CurrentUserChannel_Closing); } #endregion #region Connection Handling void CurrentUserChannel_Closing(object sender, EventArgs e) { HandleChannel(sender as IContextChannel); } void CurrentUserChannel_Faulted(object sender, EventArgs e) { HandleChannel(sender as IContextChannel); } private void HandleChannel(IContextChannel channel) { if (channel.State == CommunicationState.Closing || channel.State == CommunicationState.Faulted) { lock (syncObj) { if (_users.ContainsKey(channel)) { _users.Remove(channel); } } } } #endregion Need the help of professionals. How do I convert an existing source code for the server? Here's the code: http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=25261&zep=WCFWPFApp/ServiceAssembly/ChatService.cs&rzp=/KB/IP/WCFWPFChatRoot//wcfwpfapp.zip
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)