Skip to content

Websocket External

Websocket external is not built-in to GamanJS, what I mean here is that we just want to convey: GamanJS can also install other Websocket libraries, for example like socket.io and the like.

Here I will give an example of a websocket library that is widely known by developers in the world, namely socket.io.

GamanJS is a framework for backend applications, you can install using your favorite package manager:

Terminal window
npm install socket.io
index.ts
import { Server } from 'socket.io';
defineBootstrap(async (app) => {
const server = await app.mountSever(":3431");
const io = new Server(server);
io.on('connection', (socket) => {
console.log('a user connected');
});
});
<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io();
</script>