Skip to content

Commit

Permalink
Added typescript for websocket req to client obj (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnought authored and mcollina committed Sep 14, 2019
1 parent 18aeb22 commit 24b73f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
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

0 comments on commit 24b73f5

Please sign in to comment.