示例#1
0
        public void DeleteRoom(string name, string owner)
        {
            // delete the room from the db
            var room = _roomDatabase.Load(name);

            // already deleted from the db?
            if (room == null)
            {
                // maybe it was only in memory
                if (rooms.ContainsKey(name))
                {
                    rooms.Remove(name);
                    return;
                }
                throw new RoomNotFoundException("room not found: " + name);
            }

            if (room.Owner != owner)
            {
                throw new Exception("not owner");
            }
            _roomDatabase.Delete(name);

            // unsubscribe everyone
            var chatRoom = GetRoom(name);

            chatRoom.Broadcast(new ChatMessage
            {
                Room    = name,
                Message = "this room was deleted",
                Sender  = "[System]"
            });
            rooms.Remove(name); // this probably leaked a bunch of stuff
        }
示例#2
0
 public void Delete(string id)
 {
     db.Delete(id);
     // TODO notify
 }