+<a class="anchor" id="a5b5b1a66eda2d0e6884de8f7e25e2346"></a><!-- doxytag: member="pp::Instance::RegisterMessageHandler" ref="a5b5b1a66eda2d0e6884de8f7e25e2346" args="(MessageHandler *message_handler, const MessageLoop &message_loop)" -->
+<div class="memitem">
+<div class="memproto">
+<table class="memname">
+<tr>
+<td class="memname">int32_t <a class="el" href="classpp_1_1_instance.html#a5b5b1a66eda2d0e6884de8f7e25e2346">pp::Instance::RegisterMessageHandler</a> </td>
+<td>(</td>
+<td class="paramtype"><a class="el" href="classpp_1_1_message_handler.html">MessageHandler</a> * </td>
+<td class="paramname"><em>message_handler</em>, </td>
+</tr>
+<tr>
+<td class="paramkey"></td>
+<td></td>
+<td class="paramtype">const <a class="el" href="classpp_1_1_message_loop.html">MessageLoop</a> & </td>
+<td class="paramname"><em>message_loop</em> </td>
+</tr>
+<tr>
+<td></td>
+<td>)</td>
+<td></td><td></td>
+</tr>
+</table>
+</div>
+<div class="memdoc">
+<p>Dev-Channel Only. </p>
+<p>Registers a handler for receiving messages from JavaScript. If a handler is registered this way, it will replace the <a class="el" href="classpp_1_1_instance.html">Instance</a>'s HandleMessage method, and all messages sent from JavaScript via postMessage and postMessageAndAwaitResponse will be dispatched to <code>message_handler</code>.</p>
+<p>The function calls will be dispatched via <code>message_loop</code>. This means that the functions will be invoked on the thread to which <code>message_loop</code> is attached, when <code>message_loop</code> is run. It is illegal to pass the main thread message loop; RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case. If you quit <code>message_loop</code> before calling Unregister(), the browser will not be able to call functions in the plugin's message handler any more. That could mean missing some messages or could cause a leak if you depend on Destroy() to free hander data. So you should, whenever possible, Unregister() the handler prior to quitting its event loop.</p>
+<p>Attempting to register a message handler when one is already registered will cause the current <a class="el" href="classpp_1_1_message_handler.html" title="MessageHandler is an abstract base class that the plugin may implement if it wants to receive message...">MessageHandler</a> to be unregistered and replaced. In that case, no messages will be sent to the "default" message handler (<a class="el" href="classpp_1_1_instance.html#a5dce8c8b36b1df7cfcc12e42397a35e8" title="HandleMessage() is a function that the browser calls when PostMessage() is invoked on the DOM element...">pp::Instance::HandleMessage()</a>). Messages will stop arriving at the prior message handler and will begin to be dispatched at the new message handler.</p>
+<dl class="params"><dt><b>Parameters:</b></dt><dd>
+<table class="params">
+<tr><td class="paramdir">[in]</td><td class="paramname">message_handler</td><td>The plugin-provided object for handling messages. The instance does not take ownership of the pointer; it is up to the plugin to ensure that |message_handler| lives until its WasUnregistered() function is invoked. </td></tr>
+<tr><td class="paramdir">[in]</td><td class="paramname">message_loop</td><td>Represents the message loop on which <a class="el" href="classpp_1_1_message_handler.html" title="MessageHandler is an abstract base class that the plugin may implement if it wants to receive message...">MessageHandler</a>'s functions should be invoked. </td></tr>
+</table>
+</dd>
+</dl>
+<dl class="return"><dt><b>Returns:</b></dt><dd>PP_OK on success, or an error from pp_errors.h. </dd></dl>
+</div>
+</div>