Skip to content

Commit

Permalink
fix: Changed how the tcp connection resolves
Browse files Browse the repository at this point in the history
  • Loading branch information
juliuscc committed May 4, 2019
1 parent 00f8cd4 commit f850f84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions __mocks__/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export function __setOn(newOn: any) {
on = newOn
}

export function createConnection(_port: number, _host: string) {
return { write: () => {}, on }
export function createConnection(_options: object, callback: Function) {
callback({ write: () => {}, on })
}

const net = { createConnection, __setOn, __setOnData, __setOnError }
Expand Down
8 changes: 4 additions & 4 deletions src/connection/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ function createHeosSocket(address: string, responseParser: ResponseParser): Prom
const port: number = DEFAULT_PORT

try {
const socket: Socket = createConnection(port, host)
const socket: Socket = createConnection({ port, host }, () => {
resolve(socket)
})

socket.on('data', (data: string) => responseParser.put(data))

socket.on('timeout', reject)

resolve(socket)
socket.on('error', reject)
} catch (error) {
reject(error)
}
Expand Down

0 comments on commit f850f84

Please sign in to comment.