2.0.30 • Published 1 month ago

easy-socket-event v2.0.30

Weekly downloads
-
License
ISC
Repository
github
Last release
1 month ago

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 month ago

2.0.30

1 month ago

2.0.27

1 month ago

2.0.26

7 months ago

2.0.25

8 months ago

2.0.24

8 months ago

2.0.23

8 months ago

2.0.22

8 months ago

2.0.21

8 months ago

2.0.20

8 months ago

2.0.19

8 months ago

2.0.18

8 months ago

2.0.17

8 months ago

2.0.16

8 months ago

2.0.15

8 months ago

2.0.14

8 months ago

2.0.13

8 months ago

2.0.12

8 months ago

2.0.11

8 months ago

2.0.10

8 months ago

2.0.9

8 months ago

2.0.8

8 months ago

2.0.7

8 months ago

2.0.6

8 months ago

2.0.5

8 months ago

2.0.3

8 months ago

2.0.2

8 months ago

2.0.1

8 months ago

2.0.0

8 months ago

1.0.31

8 months ago

1.0.30

8 months ago

1.0.29

8 months ago

1.0.27

8 months ago

1.0.26

8 months ago

1.0.25

8 months ago

1.0.24

8 months ago

1.0.23

8 months ago

1.0.22

8 months ago

1.0.21

8 months ago

1.0.19

8 months ago

1.0.18

8 months ago

1.0.17

8 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.13

8 months ago

1.0.12

8 months ago

1.0.11

8 months ago

1.0.10

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago