8000 GitHub - realrandolph/autochat: a minimalist websocket-based chat page
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

realrandolph/autochat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

websocket-server

This is a backend websocket server in JavaScript that handles user connections, shares state, and passes user messages on to a queue as well as broadcasts user messages to other connected users. Prerequisites

Node.js

Installation

Clone the repository

git clone https://github.com/your-username/websocket-server.git

Install dependencies

npm install

Usage

Start the server

node index.js

Write a client to connect to the server

Here is an example of a client in JavaScript that connects to the server and sends and receives messages:

const WebSocket = require('ws');

const ws = new WebSocket('ws://localhost:8080');

ws.on('open', () => {
  console.log('Connected to server');

  // Send a message to the server
  ws.send('Hello, server!');
});

ws.on('message', (message) => {
  console.log(`Received message from server: ${message}`);
});

ws.on('close', () => {
  console.log('Disconnected from server');
});

This client connects to the server at ws://localhost:8080, and whenever it receives a message from the server, it logs the message to the console.

About

a minimalist websocket-based chat page

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0