Skip to content

Commit

Permalink
refactor(api): update conduit javascript to reflect new api
Browse files Browse the repository at this point in the history
  • Loading branch information
heapwolf committed Jun 28, 2024
1 parent 9e20235 commit 4a1d00b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions api/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,12 +512,11 @@ async function send (socket, options, callback) {
})

if (socket.conduit) {
const headers = {
socket.conduit.send({
route: 'udp.send',
port: options.port,
address: options.address
}

socket.conduit.send(headers, options.buffer)
}, options.buffer)
result = { data: true }
} else {
result = await ipc.write('udp.send', {
Expand Down Expand Up @@ -774,7 +773,7 @@ export class Socket extends EventEmitter {
}

if (this.highThroughput) {
this.conduit = new Conduit({ method: 'udp.send', id: this.id })
this.conduit = new Conduit({ id: this.id })

this.conduit.receive(({ headers, payload }) => {
const rinfo = {
Expand Down
4 changes: 2 additions & 2 deletions api/internal/conduit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class Conduit {
* @param {string} params.id - The ID for the connection.
* @param {string} params.method - The method to use for the connection.
*/
constructor ({ id, method }) {
constructor ({ id, route }) {
const port = globalThis.__args.conduit
const uri = `ws://localhost:${port}/${method}?id=${id}`
const uri = `ws://localhost:${port}/${route}/${id}`
this.socket = new globalThis.WebSocket(uri)
}

Expand Down

0 comments on commit 4a1d00b

Please sign in to comment.