| 1 |
<html> |
|---|
| 2 |
<head> |
|---|
| 3 |
<script type="text/javascript"> |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
function init() { |
|---|
| 7 |
var appName = document.getElementById("appName").value; |
|---|
| 8 |
var greetMsg = document.getElementById("greetMsg").value; |
|---|
| 9 |
if (appName == "" || greetMsg == "") { |
|---|
| 10 |
ivyRequest.init(); |
|---|
| 11 |
} else { |
|---|
| 12 |
ivyRequest.init(appName, greetMsg); |
|---|
| 13 |
} |
|---|
| 14 |
setStatus(); |
|---|
| 15 |
alert("Init done"); |
|---|
| 16 |
} |
|---|
| 17 |
|
|---|
| 18 |
function start() { |
|---|
| 19 |
var bus = document.getElementById("bus").value; |
|---|
| 20 |
if (bus == null) { |
|---|
| 21 |
ivyRequest.start(); |
|---|
| 22 |
} else { |
|---|
| 23 |
ivyRequest.start(bus); |
|---|
| 24 |
} |
|---|
| 25 |
setStatus(); |
|---|
| 26 |
alert("Start done"); |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
function run() { |
|---|
| 30 |
ivyRequest.run(); |
|---|
| 31 |
setStatus(); |
|---|
| 32 |
alert("Run done"); |
|---|
| 33 |
} |
|---|
| 34 |
|
|---|
| 35 |
function stop() { |
|---|
| 36 |
alert(ivyRequest.stop()); |
|---|
| 37 |
setStatus(); |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
function send() { |
|---|
| 42 |
var txt = document.getElementById("sendMsg").value; |
|---|
| 43 |
ivyRequest.send(txt); |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
function addMsgListener () { |
|---|
| 48 |
var regExp = document.getElementById("regExp").value; |
|---|
| 49 |
alert(ivyRequest.addIvyMsgListener (msgCallback, regExp)); |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
function removeMsgListener () { |
|---|
| 53 |
var regExp = document.getElementById("regExp").value; |
|---|
| 54 |
alert(ivyRequest.removeIvyMsgListener (msgCallback, regExp)); |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
function addConnectListener() { |
|---|
| 58 |
ivyRequest.setConnectListener(applicationConnectionCallback); |
|---|
| 59 |
alert("addConnectListener done"); |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
function removeConnectListener() { |
|---|
| 63 |
ivyRequest.setConnectListener(); |
|---|
| 64 |
alert("setConnectListener() done"); |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
function addDisconnectListener() { |
|---|
| 68 |
ivyRequest.setDisconnectListener(applicationDisconnectionCallback); |
|---|
| 69 |
alert("setDisconnectListener done"); |
|---|
| 70 |
} |
|---|
| 71 |
|
|---|
| 72 |
function removeDisconnectListener() { |
|---|
| 73 |
ivyRequest.setDisconnectListener(); |
|---|
| 74 |
alert("setDisconnectListener() done"); |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
function removeAllListeners() { |
|---|
| 78 |
ivyRequest.removeAllIvyListeners(); |
|---|
| 79 |
alert("removeAllIvyListener done"); |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
function removeAllMsgListeners() { |
|---|
| 83 |
ivyRequest.removeAllIvyMsgListeners(); |
|---|
| 84 |
alert("removeAllIvyMsgListener done"); |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
function msgCallback(name, host, args) { |
|---|
| 89 |
alert("Callbacking form " + name + "@" + host + "with args \'" + args + "\'"); |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
function applicationConnectionCallback(name, host) { |
|---|
| 93 |
alert("Connection from " + name + "@" + host); |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
function applicationDisconnectionCallback(name, host) { |
|---|
| 97 |
alert("Disconnection from " + name + "@" + host); |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
function closeIvy() { |
|---|
| 101 |
ivyRequest.close(); |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
function setStatus() { |
|---|
| 105 |
var stat = document.getElementById("statusText"); |
|---|
| 106 |
stat.innerHTML = ivyRequest.getStatus(); |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
</script> |
|---|
| 110 |
</head> |
|---|
| 111 |
<body onload="setStatus()" onclose="clostIvy()"> |
|---|
| 112 |
<div id="init" style="background-color: green"> |
|---|
| 113 |
<p>Application message : <input id="appName"/></p> |
|---|
| 114 |
<p>Greeting message : <input id="greetMsg"/> |
|---|
| 115 |
<button onclick="init()">Ivy </button></p> |
|---|
| 116 |
</div> |
|---|
| 117 |
<div style="background-color: orange"> |
|---|
| 118 |
<p> Bus to listen to (leave it blank if you do not know)</p> |
|---|
| 119 |
<p> |
|---|
| 120 |
<input id="bus"/> |
|---|
| 121 |
<button onclick="start()">Start</button> |
|---|
| 122 |
</p> |
|---|
| 123 |
</div> |
|---|
| 124 |
<div id="start" style="background-color:red"> |
|---|
| 125 |
<button onclick="run()">Run </button> |
|---|
| 126 |
<button onclick="stop()">Stop </button> |
|---|
| 127 |
<p>Once started, you cannot change previous (above) option </p> |
|---|
| 128 |
<p>Stopping the bus will automatically deleted |
|---|
| 129 |
<b>all</b> listeners </p> |
|---|
| 130 |
</div> |
|---|
| 131 |
<div style="background-color: blue; color: white"> |
|---|
| 132 |
<p>Message to send <input id="sendMsg"/> |
|---|
| 133 |
<button onclick="send()">Send</button></p> |
|---|
| 134 |
</div> |
|---|
| 135 |
<div id="listener" style="background-color: yellow"> |
|---|
| 136 |
<p>RegExp to listen to <input id="regExp"/> |
|---|
| 137 |
<button onclick="addMsgListener()">Add</button> |
|---|
| 138 |
<button onclick="removeMsgListener()">Remove</button></p> |
|---|
| 139 |
<p>Listen to application connection |
|---|
| 140 |
<button onclick="addConnectListener()">Add</button> |
|---|
| 141 |
<button onclick="removeConnectListener()">Remove</button> |
|---|
| 142 |
</p> |
|---|
| 143 |
<p>Listen to application disconnection |
|---|
| 144 |
<button onclick="addDisconnectListener()">Add</button> |
|---|
| 145 |
<button onclick="removeDisconnectListener()">Remove</button> |
|---|
| 146 |
</p> |
|---|
| 147 |
<p><button onclick="removeAllListeners()" style="border: 5px solid black">Remove all listener </button></p> |
|---|
| 148 |
<p><button onclick="removeAllMsgListeners()" style="border: 5px solid black">Remove all message listener </button></p> |
|---|
| 149 |
|
|---|
| 150 |
</div> |
|---|
| 151 |
<div id="status"> |
|---|
| 152 |
<span>Status : </span> |
|---|
| 153 |
<span id="statusText" style="color:red"></span> |
|---|
| 154 |
</div> |
|---|
| 155 |
</body> |
|---|
| 156 |
</html> |
|---|