Skip to content

Commit 111fb3c

Browse files
committed
chat app upgrade
1 parent ace7ed3 commit 111fb3c

13 files changed

Lines changed: 49 additions & 7 deletions

File tree

examples/chat/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Manuel Lõhmus
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

examples/chat/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Chat Application (example)
2+
3+
## Overview
4+
This is a simple chat application built using JavaScript.
5+
It allows users to send and receive messages in real-time.
6+
7+
## Installation
8+
1. Clone the repository or create a new folder and copy the files into it: app.js index.html package.json
9+
2. Navigate to the project directory. <br> ![File](readme_files/file.png)
10+
3. Install dependencies: `npm install` <br> ![Install](readme_files/install.png)
11+
12+
## Usage
13+
1. Start the development server: `npm start` <br> ![Start](readme_files/start.png) <br> The server has started. <br> ![Runs](readme_files/runs.png)
14+
2. Open your browser and navigate to [`http://localhost:3000`](http://localhost:3000). <br> ![Browser](readme_files/browser.png) <br> ![Debug](readme_files/debug.png)
15+
16+
## License
17+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

examples/chat/app.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,7 @@ server.listen(3000, 'localhost', function () {
139139
// server started successfully
140140
console.log('Server running at http://localhost:3000/');
141141
console.log('Open the browser and go to http://localhost:3000/ to connect to the websocket server.');
142-
});
142+
});
143+
144+
// The server will automatically shut down after 5 minutes (300000 milliseconds)
145+
setTimeout(function () { process.exit(); }, 300000);

examples/chat/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<html xmlns="http://www.w3.org/1999/xhtml">
44
<head>
55
<meta charset="utf-8" />
6-
<title>WebSocket Test</title>
6+
<title>Chat Application (example)</title>
77
<style type="text/css">
88
html, body {
99
font: normal 0.9em arial,helvetica;
@@ -136,7 +136,7 @@
136136
</script>
137137
</head>
138138
<body onload="init()">
139-
<h3>WebSocket Test</h3>
139+
<h3>Chat Application (example)</h3>
140140
<table>
141141
<tr><td><span id="status"></span> <span id="selectProtocol"></span></td></tr>
142142
<tr><td><div id="log"></div></td></tr>

examples/chat/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/chat/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "app.js",
66
"type": "module",
77
"scripts": {
8+
"start": "node app",
89
"test": "echo \"Error: no test specified\" && exit 1"
910
},
1011
"keywords": [],
29.8 KB
Loading
50.6 KB
Loading
34.5 KB
Loading
13.1 KB
Loading

0 commit comments

Comments
 (0)