Skip to content

Commit

Permalink
Added reusing Device ID without session tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjornskjald committed Jun 14, 2019
1 parent 400073a commit a74d400
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ import { AttachmentNotFoundError, AttachmentURLMissingError } from './types/Erro
import StrictEventEmitter from 'strict-event-emitter-types'
import ClientEvents from './ClientEvents'
import * as Payloads from './mqtt/payloads'
import DeviceId from './types/DeviceId'

const debugLog = debug('fblib')

export interface ClientOptions {
selfListen?: boolean
session?: Session
deviceId?: DeviceId
}

type ClientEmitter = StrictEventEmitter<EventEmitter, ClientEvents>
Expand Down Expand Up @@ -51,6 +53,10 @@ export default class Client extends (EventEmitter as { new(): ClientEmitter }) {
session = { tokens: null, deviceId: null }
}

if (options.deviceId) {
session.deviceId = options.deviceId
}

if (!session.deviceId) {
const deviceId = makeDeviceId()
session.deviceId = deviceId
Expand Down

0 comments on commit a74d400

Please sign in to comment.