Ejemplo n.º 1
0
 /// <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);
 }
Ejemplo n.º 2
0
 public IEnumerable<User> GetUsersToNotify(User user) {
     return registeredUsers.Values.Where(u => u.Callback != user.Callback && u.State.HasValue && u.State.Value == CommunicationState.Opened);
 }
Ejemplo n.º 3
0
 /// <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);
 }
Ejemplo n.º 4
0
 /// <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;
 }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
0
 /// <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);
 }
Ejemplo n.º 7
0
 /// <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);
 }
Ejemplo n.º 8
0
 /// <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();
 }
Ejemplo n.º 9
0
 /// <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);
 }
Ejemplo n.º 10
0
 /// <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);
 }
Ejemplo n.º 11
0
 /// <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);
 }
Ejemplo n.º 12
0
 /// <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);
 }
Ejemplo n.º 13
0
 /// <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);
 }