Skip to content

Commit

Permalink
fix(sio): expose type of default engine
Browse files Browse the repository at this point in the history
Related: #4693
  • Loading branch information
darrachequesne committed Sep 20, 2024
1 parent d5095fe commit 132d05f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions packages/engine.io/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,9 @@ class WebSocketResponse {
}
}

/**
* An Engine.IO server based on Node.js built-in HTTP server and the `ws` package for WebSocket connections.
*/
export class Server extends BaseServer {
public httpServer?: HttpServer;
private ws: any;
Expand Down
4 changes: 4 additions & 0 deletions packages/engine.io/lib/userver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export interface uOptions {
maxBackpressure?: number;
}

/**
* An Engine.IO server based on the `uWebSockets.js` package.
*/
// TODO export it into its own package
export class uServer extends BaseServer {
protected init() {}
protected cleanup() {}
Expand Down
12 changes: 5 additions & 7 deletions packages/socket.io/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import accepts = require("accepts");
import { pipeline } from "stream";
import path = require("path");
import { attach, Server as Engine, uServer } from "engine.io";
import type {
ServerOptions as EngineOptions,
AttachOptions,
BaseServer,
} from "engine.io";
import type { ServerOptions as EngineOptions, AttachOptions } from "engine.io";
import { Client } from "./client";
import { EventEmitter } from "events";
import { ExtendedError, Namespace, ServerReservedEventsMap } from "./namespace";
Expand Down Expand Up @@ -228,7 +224,7 @@ export class Server<
* const clientsCount = io.engine.clientsCount;
*
*/
public engine: BaseServer;
public engine: Engine;
/**
* The underlying Node.js HTTP server.
*
Expand Down Expand Up @@ -712,7 +708,9 @@ export class Server<
* @param engine engine.io (or compatible) server
* @return self
*/
public bind(engine: BaseServer): this {
public bind(engine: any): this {
// TODO apply strict types to the engine: "connection" event, `close()` and a method to serve static content
// this would allow to provide any custom engine, like one based on Deno or Bun built-in HTTP server
this.engine = engine;
this.engine.on("connection", this.onconnection.bind(this));
return this;
Expand Down

0 comments on commit 132d05f

Please sign in to comment.