/// <summary> /// Joins the chat /// </summary> public ActionResult JoinChat(string userName, string email) { // try to find an existing user with the same e-mail var dbUSer = ChatHub.FindUserByEmail(email); if (dbUSer == null) { // This is all STUB. In a normal situation, dbUSer = new DbUserStub() { FullName = userName, Email = email, Id = new Random().Next(100000), TenancyId = ChatHub.ROOM_ID_STUB }; // Normally it wouldn't be necessary to add the user to the ChatHub, because ChatHub // would get users from the database, but there's no database here ChatHub.RegisterNewUser(dbUSer); } // Normally it wouldn't be necessary to create this cookie because the // FormsAuthentication cookie does this ChatCookieHelperStub.CreateNewUserCookie(this.Response, dbUSer); return(this.RedirectToAction("Index")); }
/// <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")); }