Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFLY-19387] websocket-hello Quickstarts should have a root webpage similar to helloworld #925

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 19 additions & 95 deletions websocket-hello/src/main/webapp/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
JBoss, Home of Professional Open Source
Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual
Copyright 2024, Red Hat, Inc. and/or its affiliates, and individual
contributors by the @authors tag. See the copyright.txt in the
distribution for a full listing of individual contributors.

Licensed 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
Expand All @@ -15,95 +13,21 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<title>WebSocket: Say Hello</title>
<link rel="stylesheet" type="text/css" href="resources/css/hello.css" />
<script type="text/javascript">
var websocket = null;

function connect() {
var wsProtocol = window.location.protocol == "https:" ? "wss" : "ws";
var wsURI = wsProtocol + '://' + window.location.host + window.location.pathname + 'websocket/helloName';
websocket = new WebSocket(wsURI);

websocket.onopen = function() {
displayStatus('Open');
document.getElementById('sayHello').disabled = false;
displayMessage('Connection is now open. Type a name and click Say Hello to send a message.');
};
websocket.onmessage = function(event) {
// log the event
displayMessage('The response was received! ' + event.data, 'success');
};
websocket.onerror = function(event) {
// log the event
displayMessage('Error! ' + event.data, 'error');
};
websocket.onclose = function() {
displayStatus('Closed');
displayMessage('The connection was closed or timed out. Please click the Open Connection button to reconnect.');
document.getElementById('sayHello').disabled = true;
};
}

function disconnect() {
if (websocket !== null) {
websocket.close();
websocket = null;
}
message.setAttribute("class", "message");
message.value = 'WebSocket closed.';
// log the event
}

function sendMessage() {
if (websocket !== null) {
var content = document.getElementById('name').value;
websocket.send(content);
} else {
displayMessage('WebSocket connection is not established. Please click the Open Connection button.', 'error');
}
}

function displayMessage(data, style) {
var message = document.getElementById('hellomessage');
message.setAttribute("class", style);
message.value = data;
}

function displayStatus(status) {
var currentStatus = document.getElementById('currentstatus');
currentStatus.value = status;
}

</script>
</head>
<body>

<div>
<h1>Welcome to Red Hat JBoss Enterprise Application Platform!</h1>
<div>This is a simple example of a WebSocket implementation.</div>
<div id="connect-container">
<div>
<fieldset>
<legend>Connect or disconnect using websocket :</legend>
<input type="button" id="connect" onclick="connect();" value="Open Connection" />
<input type="button" id="disconnect" onclick="disconnect();" value="Close Connection" />
</fieldset>
</div>
<div>
<fieldset>
<legend>Type your name below, then click the `Say Hello` button :</legend>
<input id="name" type="text" size="40" style="width: 40%"/>
<input type="button" id="sayHello" onclick="sendMessage();" value="Say Hello" disabled="disabled"/>
</fieldset>
</div>
<div>Current WebSocket Connection Status: <output id="currentstatus" class="message">Closed</output></div>
<div>
<output id="hellomessage" />
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<!-- Plain HTML page that kicks us into the app -->

<html lang="en">
<head>
<meta charset="UTF-8">
<title>websocket-hello</title>
</head>
<body>
<div style="text-align:center">

<h1>Hello There! Welcome to WildFly!</h1>
<h2>The websocket-hello application has been deployed and running successfully.</h2>
<a href="welcome.html" title="Go to the application">Access the websocket-hello application here</a>

</div>
</body>
</html>
109 changes: 109 additions & 0 deletions websocket-hello/src/main/webapp/welcome.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
JBoss, Home of Professional Open Source
Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual
contributors by the @authors tag. See the copyright.txt in the
distribution for a full listing of individual contributors.

Licensed 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>WebSocket: Say Hello</title>
<link rel="stylesheet" type="text/css" href="resources/css/hello.css" />
<script type="text/javascript">
var websocket = null;

function connect() {
var wsProtocol = window.location.protocol == "https:" ? "wss" : "ws";
var wsURI = wsProtocol + '://' + window.location.host + window.location.pathname + '/../websocket/helloName';
websocket = new WebSocket(wsURI);

websocket.onopen = function() {
displayStatus('Open');
document.getElementById('sayHello').disabled = false;
displayMessage('Connection is now open. Type a name and click Say Hello to send a message.');
};
websocket.onmessage = function(event) {
// log the event
displayMessage('The response was received! ' + event.data, 'success');
};
websocket.onerror = function(event) {
// log the event
displayMessage('Error! ' + event.data, 'error');
};
websocket.onclose = function() {
displayStatus('Closed');
displayMessage('The connection was closed or timed out. Please click the Open Connection button to reconnect.');
document.getElementById('sayHello').disabled = true;
};
}

function disconnect() {
if (websocket !== null) {
websocket.close();
websocket = null;
}
message.setAttribute("class", "message");
message.value = 'WebSocket closed.';
// log the event
}

function sendMessage() {
if (websocket !== null) {
var content = document.getElementById('name').value;
websocket.send(content);
} else {
displayMessage('WebSocket connection is not established. Please click the Open Connection button.', 'error');
}
}

function displayMessage(data, style) {
var message = document.getElementById('hellomessage');
message.setAttribute("class", style);
message.value = data;
}

function displayStatus(status) {
var currentStatus = document.getElementById('currentstatus');
currentStatus.value = status;
}

</script>
</head>
<body>

<div>
<h1>Welcome to Red Hat JBoss Enterprise Application Platform!</h1>
<div>This is a simple example of a WebSocket implementation.</div>
<div id="connect-container">
<div>
<fieldset>
<legend>Connect or disconnect using websocket :</legend>
<input type="button" id="connect" onclick="connect();" value="Open Connection" />
<input type="button" id="disconnect" onclick="disconnect();" value="Close Connection" />
</fieldset>
</div>
<div>
<fieldset>
<legend>Type your name below, then click the `Say Hello` button :</legend>
<input id="name" type="text" size="40" style="width: 40%"/>
<input type="button" id="sayHello" onclick="sendMessage();" value="Say Hello" disabled="disabled"/>
</fieldset>
</div>
<div>Current WebSocket Connection Status: <output id="currentstatus" class="message">Closed</output></div>
<div>
<output id="hellomessage" />
</div>
</div>
</div>
</body>
</html>