@deepkit/rpc-tcp
Advanced tools
Comparing version
@@ -6,2 +6,8 @@ # Change Log | ||
## [1.0.1-alpha.153](https://github.com/deepkit/deepkit-framework/compare/v1.0.1-alpha.152...v1.0.1-alpha.153) (2024-06-06) | ||
### Features | ||
- **rpc:** add http transport ([3b2c6cc](https://github.com/deepkit/deepkit-framework/commit/3b2c6cc6c75d70e3b6bfac7d53e3e7606696baf4)) | ||
## [1.0.1-alpha.152](https://github.com/deepkit/deepkit-framework/compare/v1.0.1-alpha.151...v1.0.1-alpha.152) (2024-05-16) | ||
@@ -8,0 +14,0 @@ |
@@ -1,6 +0,6 @@ | ||
import { ClientTransportAdapter, TransportConnectionHooks } from '@deepkit/rpc'; | ||
import { ClientTransportAdapter, TransportClientConnection } from '@deepkit/rpc'; | ||
export declare class RpcTcpClientAdapter implements ClientTransportAdapter { | ||
protected host: import("@deepkit/core").ParsedHost; | ||
constructor(host: string); | ||
connect(connection: TransportConnectionHooks): Promise<void>; | ||
connect(connection: TransportClientConnection): Promise<void>; | ||
} |
@@ -20,6 +20,6 @@ "use strict"; | ||
socket.on('data', (data) => { | ||
connection.onData(data); | ||
connection.readBinary(data); | ||
}); | ||
socket.on('close', () => { | ||
connection.onClose(); | ||
connection.onClose('socket closed'); | ||
}); | ||
@@ -42,3 +42,3 @@ socket.on('error', (error) => { | ||
}, | ||
send(message) { | ||
writeBinary(message) { | ||
socket.write(message); | ||
@@ -45,0 +45,0 @@ } |
@@ -34,3 +34,3 @@ "use strict"; | ||
write(b) { | ||
socket.write(b); | ||
connection.sendBinary(b, (data) => socket.write(data)); | ||
}, | ||
@@ -88,4 +88,4 @@ clientAddress() { | ||
const connection = this.kernel?.createConnection({ | ||
write(b) { | ||
ws.send(b); | ||
writeBinary(message) { | ||
ws.send(message); | ||
}, | ||
@@ -92,0 +92,0 @@ close() { |
@@ -1,6 +0,6 @@ | ||
import { ClientTransportAdapter, TransportConnectionHooks } from '@deepkit/rpc'; | ||
import { ClientTransportAdapter, TransportClientConnection } from '@deepkit/rpc'; | ||
export declare class RpcTcpClientAdapter implements ClientTransportAdapter { | ||
protected host: import("@deepkit/core").ParsedHost; | ||
constructor(host: string); | ||
connect(connection: TransportConnectionHooks): Promise<void>; | ||
connect(connection: TransportClientConnection): Promise<void>; | ||
} |
@@ -17,6 +17,6 @@ import { parseHost } from '@deepkit/core'; | ||
socket.on('data', (data) => { | ||
connection.onData(data); | ||
connection.readBinary(data); | ||
}); | ||
socket.on('close', () => { | ||
connection.onClose(); | ||
connection.onClose('socket closed'); | ||
}); | ||
@@ -39,3 +39,3 @@ socket.on('error', (error) => { | ||
}, | ||
send(message) { | ||
writeBinary(message) { | ||
socket.write(message); | ||
@@ -42,0 +42,0 @@ } |
@@ -31,3 +31,3 @@ import { asyncOperation, parseHost } from '@deepkit/core'; | ||
write(b) { | ||
socket.write(b); | ||
connection.sendBinary(b, (data) => socket.write(data)); | ||
}, | ||
@@ -84,4 +84,4 @@ clientAddress() { | ||
const connection = this.kernel?.createConnection({ | ||
write(b) { | ||
ws.send(b); | ||
writeBinary(message) { | ||
ws.send(message); | ||
}, | ||
@@ -88,0 +88,0 @@ close() { |
{ | ||
"name": "@deepkit/rpc-tcp", | ||
"version": "1.0.1-alpha.152", | ||
"version": "1.0.1-alpha.153", | ||
"type": "commonjs", | ||
@@ -33,3 +33,3 @@ "main": "./dist/cjs/index.js", | ||
"devDependencies": { | ||
"@deepkit/rpc": "^1.0.1-alpha.152" | ||
"@deepkit/rpc": "^1.0.1-alpha.153" | ||
}, | ||
@@ -53,3 +53,3 @@ "jest": { | ||
}, | ||
"gitHead": "6ad04d3575b32398c79ae149db09117413b7fd7d" | ||
"gitHead": "2332134c441e8c827d9ef4125ce80afdb37e94cf" | ||
} |
import { parseHost } from '@deepkit/core'; | ||
import { ClientTransportAdapter, TransportConnectionHooks } from '@deepkit/rpc'; | ||
import { ClientTransportAdapter, TransportClientConnection } from '@deepkit/rpc'; | ||
import { connect } from 'net'; | ||
@@ -17,3 +17,3 @@ | ||
public async connect(connection: TransportConnectionHooks) { | ||
public async connect(connection: TransportClientConnection) { | ||
const port = this.host.port || 8811; | ||
@@ -26,7 +26,7 @@ const socket = this.host.isUnixSocket ? connect({ path: this.host.unixSocket }) : connect({ | ||
socket.on('data', (data: Uint8Array) => { | ||
connection.onData(data); | ||
connection.readBinary(data); | ||
}); | ||
socket.on('close', () => { | ||
connection.onClose(); | ||
connection.onClose('socket closed'); | ||
}); | ||
@@ -51,3 +51,3 @@ | ||
}, | ||
send(message) { | ||
writeBinary(message) { | ||
socket.write(message); | ||
@@ -54,0 +54,0 @@ } |
import { asyncOperation, ParsedHost, parseHost } from '@deepkit/core'; | ||
import { RpcKernel } from '@deepkit/rpc'; | ||
import { RpcKernel, RpcMessageDefinition } from '@deepkit/rpc'; | ||
import { existsSync, mkdirSync, unlinkSync } from 'fs'; | ||
@@ -42,4 +42,4 @@ import { createServer, Server, Socket } from 'net'; | ||
const connection = this.kernel?.createConnection({ | ||
write(b: Uint8Array) { | ||
socket.write(b); | ||
write(b: RpcMessageDefinition) { | ||
connection!.sendBinary(b, (data) => socket.write(data)); | ||
}, | ||
@@ -108,4 +108,4 @@ clientAddress(): string { | ||
const connection = this.kernel?.createConnection({ | ||
write(b) { | ||
ws.send(b); | ||
writeBinary(message) { | ||
ws.send(message); | ||
}, | ||
@@ -112,0 +112,0 @@ close() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
170332
0.36%