API

Session states:

STATE_NEW
STATE_OPEN
STATE_CLOSING
STATE_CLOSED