adds server code with 4 events