Pervasive and ad hoc computing applications are frequently deployed in dynamic networks. Due to mobility of the computing nodes, their unreliability, or a limited communication range, at any time a node may enter or leave an interaction between a group of application components. Middleware approaches have been proposed to deal with these dynamics, by supporting the dissemination (or gathering) of information in dynamic networks. In our experience however, applications frequently need to execute a complete protocol to coordinate. Existing middleware can then be used as a discovery mechanism, but offers no support for handling the protocol itself. This paper presents a middleware model that enables an easier implementation of distributed protocols that need to take into account the continuously changing context in the dynamic network. It uses roles as a first order abstraction, handles the distributed instantiation of roles in an interaction session, and maintains the session as nodes ...