How to use the rhea.once function in rhea

To help you get started, we’ve selected a few rhea examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / qpid-dispatch / console / react / src / amqp / connection.js View on Github external
clearTimeout(timer);
          // prevent future disconnects from calling reject
          rhea.removeListener("disconnected", disconnected);
          // we were just checking. we don't really want a connection
          if (options.test) {
            context.connection.close();
            this.connection = null;
          } else this.on_connection_open();
          var res = { context: context };
          if (callback) callback(res);
          resolve(res);
        }.bind(this);
        // register an event handler for when the connection opens
        rhea.once("connection_open", connection_open);
        // register an event handler for if the connection fails to open
        rhea.once("disconnected", disconnected);
        // attempt the connection
        this.connection = rhea.connect(c);
      }.bind(this)
    );
github apache / qpid-dispatch / console / stand-alone / plugin / js / amqp / connection.js View on Github external
// prevent future disconnects from calling reject
        rhea.removeListener('disconnected', disconnected);
        // we were just checking. we don't really want a connection
        if (options.test) {
          context.connection.close();
          this.connection = null;
        }
        else
          this.on_connection_open();
        var res = { context: context };
        if (callback)
          callback(res);
        resolve(res);
      }).bind(this);
      // register an event handler for when the connection opens
      rhea.once('connection_open', connection_open);
      // register an event handler for if the connection fails to open
      rhea.once('disconnected', disconnected);
      // attempt the connection
      this.connection = rhea.connect(c);
    }).bind(this));
  }
github apache / qpid-dispatch / console / stand-alone / plugin / js / amqp / connection.js View on Github external
// we were just checking. we don't really want a connection
        if (options.test) {
          context.connection.close();
          this.connection = null;
        }
        else
          this.on_connection_open();
        var res = { context: context };
        if (callback)
          callback(res);
        resolve(res);
      }).bind(this);
      // register an event handler for when the connection opens
      rhea.once('connection_open', connection_open);
      // register an event handler for if the connection fails to open
      rhea.once('disconnected', disconnected);
      // attempt the connection
      this.connection = rhea.connect(c);
    }).bind(this));
  }
github enqueuer-land / enqueuer / src / publishers / amqp10-publisher.ts View on Github external
return new Promise((resolve, reject) => {
            container.once('connection_error', (err: any) => reject(err.error));
            container.once('error', (err: any) => reject(err.error));
            container.once('sender_error', (err: any) => reject(err.error));
            container.once('disconnected', (err: any) => reject(err.error));
            container.once('rejected', (err: any) => reject(err.error));
            container.once('connection_open', (context: any) => {
                context.connection.open_sender(this.options);
            });
            container.once('sendable', (context: any) => {
                const delivery = context.sender.send(this.payload);
                this.messageReceived = new ObjectDecycler().decycle(delivery);
                context.sender.detach();
                resolve();
            });
            container.connect(this.connection);
        });
    }
github enqueuer-land / enqueuer / src / subscriptions / amqp10-subscription.ts View on Github external
return new Promise((resolve, reject) => {
            container.once('message', (context: any) => {
                resolve(context.message);
                context.connection.close();
            });
            container.once('error', reject);
        });
    }
github enqueuer-land / enqueuer / src / subscriptions / amqp10-subscription.ts View on Github external
private registerFailures(reject: any) {
        container.once('connection_close', (err: any) => this.rejectCallback('connection_close', err, reject));
        container.once('connection_error', (err: any) => this.rejectCallback('connection_error', err, reject));
        container.once('error', (err: any) => this.rejectCallback('error', err, reject));
        container.once('receiver_close', (err: any) => this.rejectCallback('receiver_close', err, reject));
    }
github enqueuer-land / enqueuer / src / subscriptions / amqp10-subscription.ts View on Github external
private registerFailures(reject: any) {
        container.once('connection_close', (err: any) => this.rejectCallback('connection_close', err, reject));
        container.once('connection_error', (err: any) => this.rejectCallback('connection_error', err, reject));
        container.once('error', (err: any) => this.rejectCallback('error', err, reject));
        container.once('receiver_close', (err: any) => this.rejectCallback('receiver_close', err, reject));
    }
github enqueuer-land / enqueuer / src / subscriptions / amqp10-subscription.ts View on Github external
return new Promise((resolve, reject) => {
            this.registerFailures(reject);
            if (this.server === true) {
                const server = container.listen(this.connection);
                server.once('listening', resolve);
                server.once('connection', server.close);
                server.once('error', (err: any) => reject(err.error));
            } else {
                container.connect(this.connection);
                this.removeFailure();
            }
            container.once('connection_open', (context: any) => {
                Logger.info(`${this.type} connection opened`);
                this.removeFailure();
                context.connection.open_receiver(this.options);
                resolve();
            });
        });
    }
github enqueuer-land / enqueuer / src / publishers / amqp10-publisher.ts View on Github external
return new Promise((resolve, reject) => {
            container.once('connection_error', (err: any) => reject(err.error));
            container.once('error', (err: any) => reject(err.error));
            container.once('sender_error', (err: any) => reject(err.error));
            container.once('disconnected', (err: any) => reject(err.error));
            container.once('rejected', (err: any) => reject(err.error));
            container.once('connection_open', (context: any) => {
                context.connection.open_sender(this.options);
            });
            container.once('sendable', (context: any) => {
                const delivery = context.sender.send(this.payload);
                this.messageReceived = new ObjectDecycler().decycle(delivery);
                context.sender.detach();
                resolve();
            });
            container.connect(this.connection);
        });
    }
github enqueuer-land / enqueuer / src / subscriptions / amqp10-subscription.ts View on Github external
return new Promise((resolve, reject) => {
            container.once('message', (context: any) => {
                resolve(context.message);
                context.connection.close();
            });
            container.once('error', reject);
        });
    }