/// <summary> /// Unregister the specified user. /// </summary> /// <param name="user"></param> /// <returns></returns> public User Unregister(User user) { if (registeredUsers.ContainsKey(user.Callback)) { registeredUsers.Remove(user.Callback); } return new User(user.Callback, user.Name, false, DateTime.Now); }
public IEnumerable<User> GetUsersToNotify(User user) { return registeredUsers.Values.Where(u => u.Callback != user.Callback && u.State.HasValue && u.State.Value == CommunicationState.Opened); }
/// <summary> /// Trace successful service call. /// </summary> /// <param name="user"></param> /// <param name="format"></param> /// <param name="arg"></param> public static void TraceCallSuccess(User user, string format, params object[] arg) { TraceSend(ConsoleColor.Green, user, format, arg); }
/// <summary> /// Register user with the specified name and callback. /// </summary> /// <param name="name"></param> /// <param name="callback"></param> /// <returns></returns> public User Register(string name, IChatCallbackContract callback) { if (registeredUsers.ContainsKey(callback)) { return registeredUsers[callback]; } var user = new User(callback, name, true, DateTime.Now); registeredUsers.Add(callback, user); return user; }
/// <summary> /// Trace successful broadcast service call. /// </summary> /// <param name="user"></param> /// <param name="format"></param> /// <param name="arg"></param> public static void TraceCallBroadcast(User user, string format, params object[] arg) { TraceSend(ConsoleColor.Cyan, user, format, arg); }
/// <summary> /// Trace failed service call. /// </summary> /// <param name="user"></param> /// <param name="format"></param> /// <param name="arg"></param> public static void TraceCallFailure(User user, string format, params object[] arg) { TraceSend(ConsoleColor.Red, user, format, arg); }
/// <summary> /// Trace successful whipser service call notification. /// </summary> /// <param name="user"></param> /// <param name="format"></param> /// <param name="arg"></param> public static void TraceNotificationWhipser(User user, string format, params object[] arg) { TraceSend(ConsoleColor.DarkMagenta, user, format, arg); }
/// <summary> /// Trace sending service call. /// </summary> /// <param name="color"></param> /// <param name="user"></param> /// <param name="format"></param> /// <param name="arg"></param> private static void TraceSend(ConsoleColor color, User user, string format, params object[] arg) { Console.ForegroundColor = color; Console.WriteLine(string.Format("[{0}] Sending {1} to {2}", DateTime.Now, format, user.Name ?? "Unknown"), arg); Console.ResetColor(); }
/// <summary> /// Trace alert service call notification. /// </summary> /// <param name="user"></param> /// <param name="format"></param> /// <param name="arg"></param> public static void TraceNotificationWarning(User user, string format, params object[] arg) { TraceSend(ConsoleColor.DarkYellow, user, format, arg); }
/// <summary> /// Trace successful service call notification. /// </summary> /// <param name="user"></param> /// <param name="format"></param> /// <param name="arg"></param> public static void TraceNotificationSuccess(User user, string format, params object[] arg) { TraceSend(ConsoleColor.DarkGreen, user, format, arg); }
/// <summary> /// Trace successful broadcast service call notification. /// </summary> /// <param name="user"></param> /// <param name="format"></param> /// <param name="arg"></param> public static void TraceNotificationBroadcast(User user, string format, params object[] arg) { TraceSend(ConsoleColor.DarkCyan, user, format, arg); }
/// <summary> /// Trace successful whipser service call. /// </summary> /// <param name="user"></param> /// <param name="format"></param> /// <param name="arg"></param> public static void TraceCallWhisper(User user, string format, params object[] arg) { TraceSend(ConsoleColor.Magenta, user, format, arg); }
/// <summary> /// Trace alert service call. /// </summary> /// <param name="user"></param> /// <param name="format"></param> /// <param name="arg"></param> public static void TraceCallWarning(User user, string format, params object[] arg) { TraceSend(ConsoleColor.Yellow, user, format, arg); }