2.0.30 • Published 2 years ago
easy-socket-event v2.0.30
Socket comunication by event
Use events to communicate via socket; Make managing socket communications between your clients and your server easier, more readable (and more typified)
Install package socket-event
Server
Create the socket server
import { SocketServer } from "socket-event/server";
const server = new SocketServer();Add an event to server
// Register the handler for an example event
server.Event<string>("example", (data: string, sender: net.Socket) => {
console.log("\"example\" event handler >>>", data);
});Liste to the server
server.Listen("localhost", 3001);Client
Create the socket client and set connected event
import { SocketClient } from "socket-event/client";
const client = new SocketClient();Create event emitter
const {emit:exampleEmit} = client.EventEmitter<string>("example");Connect the client
client.Connect("localhost", 3001);When connected, emit the event
client.connected = () => {
console.log("Client connected");
exampleEmit("Example event emit")
};2.0.29
2 years ago
2.0.30
2 years ago
2.0.27
2 years ago
2.0.26
3 years ago
2.0.25
3 years ago
2.0.24
3 years ago
2.0.23
3 years ago
2.0.22
3 years ago
2.0.21
3 years ago
2.0.20
3 years ago
2.0.19
3 years ago
2.0.18
3 years ago
2.0.17
3 years ago
2.0.16
3 years ago
2.0.15
3 years ago
2.0.14
3 years ago
2.0.13
3 years ago
2.0.12
3 years ago
2.0.11
3 years ago
2.0.10
3 years ago
2.0.9
3 years ago
2.0.8
3 years ago
2.0.7
3 years ago
2.0.6
3 years ago
2.0.5
3 years ago
2.0.3
3 years ago
2.0.2
3 years ago
2.0.1
3 years ago
2.0.0
3 years ago
1.0.31
3 years ago
1.0.30
3 years ago
1.0.29
3 years ago
1.0.27
3 years ago
1.0.26
3 years ago
1.0.25
3 years ago
1.0.24
3 years ago
1.0.23
3 years ago
1.0.22
3 years ago
1.0.21
3 years ago
1.0.19
3 years ago
1.0.18
3 years ago
1.0.17
3 years ago
1.0.16
3 years ago
1.0.15
3 years ago
1.0.14
3 years ago
1.0.13
3 years ago
1.0.12
3 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago