2.0.30 • Published 1 year 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
1 year ago
2.0.30
1 year ago
2.0.27
1 year ago
2.0.26
2 years ago
2.0.25
2 years ago
2.0.24
2 years ago
2.0.23
2 years ago
2.0.22
2 years ago
2.0.21
2 years ago
2.0.20
2 years ago
2.0.19
2 years ago
2.0.18
2 years ago
2.0.17
2 years ago
2.0.16
2 years ago
2.0.15
2 years ago
2.0.14
2 years ago
2.0.13
2 years ago
2.0.12
2 years ago
2.0.11
2 years ago
2.0.10
2 years ago
2.0.9
2 years ago
2.0.8
2 years ago
2.0.7
2 years ago
2.0.6
2 years ago
2.0.5
2 years ago
2.0.3
2 years ago
2.0.2
2 years ago
2.0.1
2 years ago
2.0.0
2 years ago
1.0.31
2 years ago
1.0.30
2 years ago
1.0.29
2 years ago
1.0.27
2 years ago
1.0.26
2 years ago
1.0.25
2 years ago
1.0.24
2 years ago
1.0.23
2 years ago
1.0.22
2 years ago
1.0.21
2 years ago
1.0.19
2 years ago
1.0.18
2 years ago
1.0.17
2 years ago
1.0.16
2 years ago
1.0.15
2 years ago
1.0.14
2 years ago
1.0.13
2 years ago
1.0.12
2 years ago
1.0.11
2 years ago
1.0.10
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago