mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-06-07 00:11:52 +00:00
remove dead exports, add XFTPAgent.closeServer method
This commit is contained in:
@@ -22,8 +22,7 @@ import {
|
||||
deleteXFTPChunk, ackXFTPChunk, XFTPAgent
|
||||
} from "./client.js"
|
||||
export {XFTPAgent, type TransportConfig,
|
||||
XFTPRetriableError, XFTPPermanentError, isRetriable, categorizeError, humanReadableMessage,
|
||||
ackXFTPChunk, addXFTPRecipients} from "./client.js"
|
||||
XFTPRetriableError, XFTPPermanentError, isRetriable, categorizeError, humanReadableMessage} from "./client.js"
|
||||
import {processDownloadedFile, decryptReceivedChunk} from "./download.js"
|
||||
import type {XFTPServer} from "./protocol/address.js"
|
||||
import {formatXFTPServer, parseXFTPServer} from "./protocol/address.js"
|
||||
|
||||
+9
-14
@@ -181,6 +181,15 @@ export class XFTPAgent {
|
||||
this._connectFn = connectFn ?? connectXFTP
|
||||
}
|
||||
|
||||
closeServer(server: XFTPServer): void {
|
||||
const key = formatXFTPServer(server)
|
||||
const conn = this.connections.get(key)
|
||||
if (conn) {
|
||||
this.connections.delete(key)
|
||||
conn.client.then(c => c.transport.close(), () => {})
|
||||
}
|
||||
}
|
||||
|
||||
close(): void {
|
||||
for (const conn of this.connections.values()) {
|
||||
conn.client.then(c => c.transport.close(), () => {})
|
||||
@@ -229,15 +238,6 @@ export function removeStaleConnection(
|
||||
}
|
||||
}
|
||||
|
||||
export function closeXFTPServerClient(agent: XFTPAgent, server: XFTPServer): void {
|
||||
const key = formatXFTPServer(server)
|
||||
const conn = agent.connections.get(key)
|
||||
if (conn) {
|
||||
agent.connections.delete(key)
|
||||
conn.client.then(c => c.transport.close(), () => {})
|
||||
}
|
||||
}
|
||||
|
||||
// -- Connect + handshake
|
||||
|
||||
export async function connectXFTP(server: XFTPServer, config?: Partial<TransportConfig>): Promise<XFTPClient> {
|
||||
@@ -448,8 +448,3 @@ export async function pingXFTP(agent: XFTPAgent, server: XFTPServer): Promise<vo
|
||||
if (response.type !== "FRPong") throw new Error("unexpected response: " + response.type)
|
||||
}
|
||||
|
||||
// -- Close
|
||||
|
||||
export function closeXFTP(c: XFTPClient): void {
|
||||
c.transport.close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user