public void Logout(string userName) { CheckinUser logoutUser = CheckinCC.GetUser(userName); CheckinCC.Users.Remove(logoutUser); foreach (var user in CheckinCC.Users) { user.Checkincallback.ShowLogout(userName); } logoutUser = null; //将其设置为null后,WCF会自动关闭该客户端 }
public void Login(string userName) { OperationContext context = OperationContext.Current; ICheckinServerCallback callback = context.GetCallbackChannel <ICheckinServerCallback>(); CheckinUser newUser = new CheckinUser(userName, callback); CheckinCC.Users.Add(newUser); foreach (var user in CheckinCC.Users) { user.Checkincallback.ShowLogin(userName); } }
public static CheckinUser GetUser(string username) { CheckinUser user = null; foreach (var item in Users) { if (item.Name == username) { user = item; break; } } return(user); }