PUN cockpi

I want to make a perfect connetcion that includes knowing when the player is connected what room he's in and such and who the players with him are with the ability to reconnect and kick etc..

i think the closes thing I saw so far is the pun cockpit demo... but i found no explanation on it.. I Need help to understand how to make such a thing or just the code explained