-
Notifications
You must be signed in to change notification settings - Fork 12
/
mod.ts
71 lines (69 loc) · 1.77 KB
/
mod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* @example
* import { serve } from "https://deno.land/[email protected]/http/server.ts";
* import { Server } from "https://deno.land/x/[email protected]/mod.ts";
*
* const io = new Server();
*
* io.on("connection", (socket) => {
* console.log(`socket ${socket.id} connected`);
*
* // send an event to the client
* socket.emit("foo", "bar");
*
* socket.on("foobar", () => {
* // an event was received from the client
* });
*
* // upon disconnection
* socket.on("disconnect", (reason) => {
* console.log(`socket ${socket.id} disconnected due to ${reason}`);
* });
* });
*
* await serve(io.handler(), {
* port: 3000,
* });
*/
export {
Adapter,
type BroadcastOptions,
type Namespace,
Server,
type ServerOptions,
type Socket,
} from "./packages/socket.io/mod.ts";
/**
* The Redis adapter, to broadcast packets between several Socket.IO servers
*
* Documentation: https://socket.io/docs/v4/redis-adapter/
*
* @example
* import { serve } from "https://deno.land/std/http/server.ts";
* import { Server, createRedisAdapter, createRedisClient } from "https://deno.land/x/socket_io/mod.ts";
*
* const [pubClient, subClient] = await Promise.all([
* createRedisClient({
* hostname: "localhost",
* }),
* createRedisClient({
* hostname: "localhost",
* })
* ]);
*
* const io = new Server({
* adapter: createRedisAdapter(pubClient, subClient)
* });
*
* await serve(io.handler(), {
* port: 3000
* });
*/
export {
createAdapter as createRedisAdapter,
type RedisAdapterOptions,
} from "./packages/socket.io-redis-adapter/mod.ts";
/**
* Temporary export to provide a workaround for https://github.com/denodrivers/redis/issues/335
*/
export { connect as createRedisClient } from "./vendor/deno.land/x/[email protected]/mod.ts";