public IEnumerable<object> GetOnlineList(string onlineList)
 {
     return MyWebSocket.OnlineList.Select(u =>
     {
         RatingInfo rating = new RatingInfo(u);
         return new
         {
             User = u,
             UserColor = rating.Color,
             UserCaption = rating.Caption
         };
     });
 }
 public object Get(DateTime before, int top)
 {
     return Chat.GetHistory(Chat.CommonSession, before, top).Select(x =>
     {
         RatingInfo rating = new RatingInfo(x.Username);
         return new
         {
             Content = x.Content,
             Time = x.Time.ToUniversalTime(),
             User = x.Username,
             UserImg = Gravatar.GetAvatarURL(USER.ByName(x.Username).Email, 50),
             UserColor = rating.Color,
             UserCaption = rating.Caption
         };
     });
 }
        public override void OnOpen()
        {
            Task toWait = null;
            bool success = true;
            lock (Clients)
            {
                if (Clients.ContainsKey(User))
                {
                    if (WebSocketContext.QueryString["forceLogin"] == "true")
                    {
                        var oldConn = Clients[User];
                        oldConn.noRemove = true;
                        toWait = Task.Run(() =>
                        {
                            oldConn.Send(JSON.Serialize(new { Type = "AnotherLogin" }));
                            oldConn.Close();
                        });

                        Clients[User] = this;
                    }
                    else
                    {
                        toWait = Task.Run(() =>
                        {
                            Send(JSON.Serialize(new { Type = "AlreadyLogin" }));
                            Close();
                        });
                        success = false;
                    }
                }
                else
                {
                    Clients.Add(User, this);
                }
            }
            if (toWait != null)
                toWait.Wait();
            //Broadcast
            var rating = new RatingInfo(User);
            Broadcast(JSON.Serialize(new
            {
                Type = "Login",
                User = User,
                UserColor = rating.Color,
                UserCaption = rating.Caption
            })).Wait();
        }