/// <summary> /// Joins the chat /// </summary> public ActionResult JoinChat(string userName, string email) { // try to find an existing user with the same e-mail var user = ChatHub.FindUserByEmail(email); if (user == null) { user = new ChatUser() { Name = userName, Email = email, ProfilePictureUrl = GravatarHelper.GetGravatarUrl(GravatarHelper.GetGravatarHash(email), GravatarHelper.Size.s32), Id = new Random().Next(100000), Status = ChatUser.StatusType.Online, RoomId = ChatController.ROOM_ID_STUB }; // for signalr { ChatHub.RegisterNewUser(user); } // for long-polling { ChatServer.SetupRoomIfNonexisting(ChatController.ROOM_ID_STUB); ChatServer.Rooms[ChatController.ROOM_ID_STUB].RegisterNewUser(user); } } // Normally it wouldn't be necessary to create this cookie because the // FormsAuthentication cookie does this ChatHelper.CreateNewUserCookie(this.Response, user); return(this.RedirectToAction("Index")); }