Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have made a new project and selected individual user accounts authentication and MVC project. Then I went on the home view, deleted all the template information in the main body and added a load of actionlinks with the names of chat rooms I want to implement. They are simply chatroom1, chatroom2 etc. There will be a set number so I dont want users to define the room names.

Moving on I then implemented a simple hub class as given in http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-server

What I want is to click on the links from the home page and they join you to that chat room. I think it is best if they are defined as groups rather than hubs, but I don't understand where to put the joining code...

I have this as my hub

SQL
public class ContosoChatHub : Hub
{
    public Task JoinGroup(string groupName)
    {
        return Groups.Add(Context.ConnectionId, groupName);
    }

    public Task LeaveGroup(string groupName)
    {
        return Groups.Remove(Context.ConnectionId, groupName);
    }
}



But where do I define where to add the user? In the controller or view (in which case which view), and moreover how! I've been looking for hours for a tutorial I can implement in this way. I also want to know how to set the username as the username registered.

Any help/guidance would be hugely appreciated
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900