Fix the webclient attempt four.
This commit is contained in:
parent
1e2a7572a6
commit
bd32940581
1 changed files with 6 additions and 1 deletions
|
|
@ -21,10 +21,14 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
const socket = io('http://localhost:5000'); // Connect to the WebSocket server
|
||||
// Ask the user for the server address
|
||||
const serverUrl = prompt("Enter the WebSocket server URL (e.g., http://localhost:5000):") || 'http://localhost:5000';
|
||||
const socket = io(serverUrl); // Connect to the WebSocket server
|
||||
|
||||
const chatDiv = document.getElementById('chat');
|
||||
const messageInput = document.getElementById('message');
|
||||
|
||||
// Ask the user for their username and chat room
|
||||
let username = prompt("Enter your username:");
|
||||
let chatRoom = prompt("Enter chat room (default: 'default')") || 'default';
|
||||
|
||||
|
|
@ -32,6 +36,7 @@
|
|||
console.log('Joining chat room:', { username: username, chat_room: chatRoom });
|
||||
socket.emit('join', { username: username, chat_room: chatRoom });
|
||||
|
||||
// Log connection status
|
||||
socket.on('connect', () => {
|
||||
console.log('Connected to WebSocket server');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue