blob: a33e02561f2811270b93a7756549ba6748c011c8 [file] [log] [blame]
<!DOCTYPE html> <!-- HTML5 doctype -->
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
<title>Simple Proton Messenger Send Example</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
Import the Messenger Binding proton.js. Note that this simple example pulls
it from the node_modules/qpid-proton/lib, which is created by the build process
so that the node.js based examples "just work", in a real Web App you would
clearly need to copy the proton.js to your own server.
In actual fact the CMake build actually builds proton.js into the directory:
where <build> is the build directory created to run cmake from, it is then
copied to the node_modules/qpid-proton/lib directory.
In this example we also set the global variable PROTON_TOTAL_MEMORY in order to
increase the virtual heap available to the emscripten compiled C runtime. It
is not really necessary to do this for this application as the default value
of 16777216 is fine, it is simply done here to illustrate how to do it.
<script type="text/javascript">PROTON_TOTAL_MEMORY = 50000000;</script>
<script type="text/javascript" src="../../../node_modules/qpid-proton-messenger/lib/proton-messenger.js"></script>
<script type="text/javascript">
var message = new proton.Message();
var messenger = new proton.Messenger();
var sendMessage = function() {
var address = document.getElementById("address").value;
var subject = document.getElementById("subject").value;
var body = document.getElementById("body").value;
console.log("address = " + address);
console.log("subject = " + subject);
console.log("body = " + body);
message.body = body;
var errorHandler = function(error) {
console.log("Received error " + error);
messenger.on('error', errorHandler);
font: 13px/1.5 Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif;
overflow-x: hidden; /* Hide horizontal scrollbar */
background: #dddddd;
display: block;
font-size: 17px;
input, textarea
font-size: 13px;
margin-bottom: 10px;
<label for="address">Address:</label>
<input type="text" id="address" size="40"
name="address" value="amqp://guest:guest@" />
<label for="subject">Subject:</label>
<input type="text" id="subject" size="40"
name="subject" value="Browser Message" />
<label for="body">Message:</label>
<textarea id="body" name="body" rows="4" cols="40">Hello From Browser!</textarea>
<input type="button" value="send" onclick="sendMessage()"/>