# Web Socket
ExpressWebJS offers a robust WebSocket Provider to serve real-time apps.
The server works on pure WebSocket connections (supported by all major browsers) and scales naturally within a cluster of Node.js processes.
# Basic Example
Let’s build a single room chat server for user messaging.
expresswebcli make-ws-controller chatController
This will generate our chatController class inside App/Http/Controller/Ws Our chatController class looks like this:
"use strict"; const WsBaseController = require("@WsBaseController"); class chatController extends WsBaseController { constructor(socket) { super(socket); this.socket = socket; } onMessage(data) { // same as: socket.on('message') this.socket.emit("message", data); console.log(data); } close() { // same as: socket.on('close') } onError() { // same as: socket.on('error') } } module.exports = chatController;
Copied!
← Routing Event Methods →