diff --git a/types/zeromq/index.d.ts b/types/zeromq/index.d.ts index 189d60fc29..d1088aba8f 100644 --- a/types/zeromq/index.d.ts +++ b/types/zeromq/index.d.ts @@ -240,3 +240,14 @@ export function createSocket(type: string, options?: any): Socket; * @return The public and secret portions of the key. */ export function curveKeypair(): CurveKeyPair; + +/** + * Connects a frontend socket to a backend socket. + * @param frontend The frontend socket to connect with the backend socket. + * Frontend socket should be a 'push', 'pull', 'xpub', 'router' or 'xrep' socket. + * @param backend The backend socket to connect with the frontend socket. + * Backend socket should be a 'pull', 'push', 'xsub', 'dealer' or 'xreq' socket. + * @param capture If defined, this socket will receive all messages from frontend and backend socket + * Capture socket should be a 'pub', 'dealer', 'push' or 'pair' socket. + */ +export function proxy(frontend: Socket, backend: Socket, capture ?: Socket): void; diff --git a/types/zeromq/zeromq-tests.ts b/types/zeromq/zeromq-tests.ts index a1230957a7..466deaf4b7 100644 --- a/types/zeromq/zeromq-tests.ts +++ b/types/zeromq/zeromq-tests.ts @@ -48,3 +48,13 @@ function test6() { sock.pause(); sock.resume(); } + +function test7() { + const xPubSocket = zeromq.socket('xpub'); + const xPSubSocket = zeromq.socket('xsub'); + + xPubSocket.bindSync(`tcp://127.0.0.1:3000`); + xPSubSocket.bindSync('tcp://127.0.0.1:3001'); + + zeromq.proxy(xPubSocket, xPSubSocket); +}