How to use the rhea-promise.Connection function in rhea-promise

To help you get started, we’ve selected a few rhea-promise 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 Azure / azure-sdk-for-js / tests / requestResponse.spec.ts View on Github external
it("should send a request and receive a response correctly", async function () {
    const connectionStub = stub(new Connection());
    const rcvr = new EventEmitter();
    let req: any = {};
    connectionStub.createSession.resolves({
      connection: {
        id: "connection-1"
      },
      createSender: () => {
        return Promise.resolve({
          send: (request: any) => {
            req = request;
          }
        });
      }, createReceiver: () => {
        return Promise.resolve(rcvr);
      }
    });
github Azure / azure-sdk-for-js / sdk / core / core-amqp / src / ConnectionContextBase.ts View on Github external
(!isNode && typeof window !== "undefined" && (window as any).WebSocket)
    ) {
      const socket = parameters.config.webSocket || (window as any).WebSocket;
      const host = parameters.config.host;
      const endpoint = parameters.config.webSocketEndpointPath || "";
      const socketOptions = parameters.config.webSocketConstructorOptions || {};

      connectionOptions.webSocketOptions = {
        webSocket: socket,
        url: `wss://${host}:443/${endpoint}`,
        protocol: ["AMQPWSB10"],
        options: socketOptions
      };
    }

    const connection = new Connection(connectionOptions);
    const connectionLock = `${Constants.establishConnection}-${generate_uuid()}`;
    const connectionContextBase: ConnectionContextBase = {
      wasConnectionCloseCalled: false,
      connectionLock: connectionLock,
      negotiateClaimLock: `${Constants.negotiateClaim}-${generate_uuid()}`,
      connection: connection,
      connectionId: connection.id,
      cbsSession: new CbsClient(connection, connectionLock),
      config: parameters.config,
      tokenCredential:
        parameters.tokenCredential ||
        new SharedKeyCredential(
          parameters.config.sharedAccessKeyName,
          parameters.config.sharedAccessKey
        ),
      dataTransformer: parameters.dataTransformer || new DefaultDataTransformer()