set connection state before emitting an event