This repository has been archived by the owner on Oct 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
/
index.html
117 lines (96 loc) · 4.31 KB
/
index.html
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
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script type="text/javascript" src="jquery/jquery-2.0.3.js"></script>
<script type="text/javascript" src="jquery/jquery.form.js"></script>
<script type="text/javascript" src="jquery/jquery.atmosphere.js"></script>
<script type="text/javascript" src="jquery/jquery.swaggersocket.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var identity = 0;
var ss = new jQuery.swaggersocket.SwaggerSocketListener();
var swaggerSocket = new jQuery.swaggersocket.SwaggerSocket();
ss.onOpen = function(r) {
$('ul').prepend($('<li></li>').text("----------------------------"));
$('ul').prepend($('<li></li>').text("STATUS: " + r.getReasonPhrase()));
$('ul').prepend($('<li></li>').text("SwaggerSocket connected"));
$('ul').prepend($('<li></li>').text("----------------------------"));
};
ss.onClose = function(r) {
$('ul').prepend($('<li></li>').text("----------------------------"));
$('ul').prepend($('<li></li>').text("STATUS: " + r.getReasonPhrase()));
$('ul').prepend($('<li></li>').text("SwaggerSocket closed; reconnecting ..."));
$('ul').prepend($('<li></li>').text("----------------------------"));
};
ss.onError = function(r) {
$('ul').prepend($('<li></li>').text("----------------------------"));
$('ul').prepend($('<li></li>').text("ERROR: " + r.getReasonPhrase()));
$('ul').prepend($('<li></li>').text("----------------------------"));
};
ss.onResponse = function(r) {
$('ul').prepend($('<li></li>').text("Response for Request: " + r.getRequest().getUUID() + " is '" + r.getData() + "'"));
};
open();
function getKeyCode(ev) {
if (window.event) return window.event.keyCode;
return ev.keyCode;
}
function getElementById() {
return document.getElementById(arguments[0]);
}
function getElementByIdValue() {
return document.getElementById(arguments[0]).value;
}
function open() {
var request = new jQuery.swaggersocket.Request()
.path(document.location.toString() + 'helloworld')
.listener(ss);
swaggerSocket.open(request);
}
getElementById('send_message').onclick = function(event) {
$('ul').prepend($('<li></li>').text("----------------------------"));
/**
* Send the hello message.
*/
var request = new jQuery.swaggersocket.Request()
.path("/sayHello")
.method("GET")
.listener(ss);
$('ul').prepend($('<li></li>').text("Sending a hello request using uuid " + request.getUUID()));
$('ul').prepend($('<li></li>').text(""));
swaggerSocket.send(request);
return false;
};
});
</script>
<style type='text/css'>
div {
border: 0px solid black;
}
ul {
list-style-type: none;
text-align: left;
}
div.hidden {
display: none;
}
span.from {
font-weight: bold;
}
span.alert {
font-style: italic;
}
</style>
</head>
<body>
<h1>Swagger Socket HelloWorld Sample.</h1>
<h2>The sample demonstrates how the swaggersocket.js works and output some information about the protocol itself. Take a look at <a href="https://github.com/swagger-api/swagger-socket/blob/master/samples/swaggersocket-helloworld/src/main/webapp/index.html">the details</a>. Under the hood swaggersocket will execute many requests using a single websocket connection. </h2>
<br/>
<h2 id="s_h" class='hidden'>Say Hello to SwaggerSocket</h2>
<div id='sendMessage'>
<input id='send_message' class='button' type='submit' name='Publish' value='Hello'/>
</div>
<br/>
<h2>Messages delivered asynchronously</h2>
<ul></ul>
</body>
</html>