removed msg double encoding, send function now takes arbitrary js type