Wrote generic client side event encoder