/// <summary> /// Returns or creats a chat room for these two users or create a new one if nothing exists /// </summary> /// <param name="user1ID"></param> /// <param name="user1Name"></param> /// <param name="user2ID"></param> /// <param name="user2Name"></param> /// <returns></returns> private static ChatRoom GetRoom(string user1ID,string user1Name,string user2ID,string user2Name) { ChatRoom room=null; string rid1=CreateRoomID(user1ID,user2ID); string rid2=CreateRoomID(user2ID,user1ID); Monitor.Enter(Rooms); if (Rooms.Contains(rid1)) room=(ChatRoom)Rooms[rid1]; else { if (Rooms.Contains(rid2)) room=(ChatRoom)Rooms[rid2]; else { //if (user1Name=="" && user2Name=="") // return null; //else room=new ChatRoom(user1ID,user1Name,user2ID,user2Name); Rooms.Add(rid1,room); } } Monitor.Exit(Rooms); return room; }