Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added typescript for websocket/http request to client object #325

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/typescript/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const broker = Server({
heartbeatInterval: 60000,
connectTimeout: 30000,
preConnect: (client: Client, callback) => {
if (client.req) {
callback(new Error('not websocket stream'), false)
}
if (client.conn.remoteAddress === '::1') {
callback(null, true)
} else {
Expand Down
2 changes: 2 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { IPublishPacket, ISubscribePacket, ISubscription, IUnsubscribePacket } from 'mqtt-packet'
import { Duplex } from 'stream'
import { Socket } from 'net'
import { IncomingMessage } from 'http'
import EventEmitter = NodeJS.EventEmitter

declare function aedes (options?: aedes.AedesOptions): aedes.Aedes
Expand All @@ -24,6 +25,7 @@ declare namespace aedes {
id: string
clean: boolean
conn: Socket
req?: IncomingMessage

on (event: 'error', cb: (err: Error) => void): this

Expand Down