File: send.html

package info (click to toggle)
qpid-proton 0.14.0-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 9,632 kB
  • ctags: 20,083
  • sloc: java: 39,624; ansic: 29,389; python: 16,581; cpp: 11,250; ruby: 6,618; perl: 2,641; php: 1,033; xml: 957; sh: 230; pascal: 52; makefile: 32
file content (122 lines) | stat: -rw-r--r-- 3,706 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!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
  
    http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
-->

<html>

<head>
	<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:
  <build>/proton-c/bindings/javascript
  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("sendMessage");
console.log("address = " + address);
console.log("subject = " + subject);
console.log("body = " + body);

    message.setAddress(address);
    message.setSubject(subject);
    message.body = body;

    messenger.put(message);
    messenger.send();
};

var errorHandler = function(error) {
    console.log("Received error " + error);
};

messenger.on('error', errorHandler);
messenger.start();

</script>

<style>
body
{
	font: 13px/1.5 Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif;
    overflow-x: hidden; /* Hide horizontal scrollbar */
    background: #dddddd;
}

label
{
    display: block;
	font-size: 17px;
}

input, textarea
{
	font-size: 13px;
    margin-bottom: 10px;
}
</style>

</head>

<body>
<div>
    <label for="address">Address:</label>
    <input type="text" id="address" size="40"
           placeholder="amqp://user:password@host:port"
           name="address" value="amqp://guest:guest@0.0.0.0" />
</div>
<div>    
    <label for="subject">Subject:</label>
    <input type="text" id="subject" size="40"
           name="subject" value="Browser Message" />
</div>
<div>
    <label for="body">Message:</label>
    <textarea id="body" name="body" rows="4" cols="40">Hello From Browser!</textarea>
</div>
<div>
    <input type="button" value="send" onclick="sendMessage()"/>
</div>
</body>

</html>