Merge pull request #23370 from TitaneBoy/@types/zeromq

@types/zeromq - Add proxy function type
This commit is contained in:
Ron Buckton
2018-02-07 18:51:18 -08:00
committed by GitHub
2 changed files with 21 additions and 0 deletions
+11
View File
@@ -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;
+10
View File
@@ -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);
}