For me the buddy system usually helps. I’m lucky in that if I’m at something of that ilk I’m with my wife, and she helps anchor me. Also, as much as some will say “that’s what alcohol is for”, I think that’s not necessarily the ultimate answer. In my case one or two drinks can help, but any more tends to be a recipe for disaster. In fact, this is the situation where I always found cigarettes helpful. They were always a good excuse to stand alone outside and gather myself if I began fraying around the edges. Sometimes, if the DJ is good and has a good playlist, music does the trick.
I don’t know if you have the same problem I do, which is that no matter how I try to keep myself secluded people seek me out. Then I channel my father and get smiley and friendly on the outside while I bristle and shudder on the inside. Sometimes I take this advice and just make sure I say some weird stuff.
Or you can just spend as much time as possible foruming on mobile.