postMessage wrapper for processing method calls, callbacks, and events