How to use the @wireapp/commons.TimeUtil.TimeInMillis function in @wireapp/commons

To help you get started, we’ve selected a few @wireapp/commons 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 wireapp / wire-web-packages / packages / api-client / src / http / HttpClient.ts View on Github external
constructor(private readonly baseUrl: string, public accessTokenStore: AccessTokenStore) {
    super();

    this.connectionState = ConnectionState.UNDEFINED;

    this.logger = logdown('@wireapp/api-client/http/HttpClient', {
      logger: console,
      markdown: false,
    });

    this.requestQueue = new PriorityQueue({
      maxRetries: 0,
      retryDelay: TimeUtil.TimeInMillis.SECOND,
    });

    // Log all failing HTTP requests
    axios.interceptors.response.use(undefined, (error: AxiosError) => {
      let backendResponse = '';

      if (error.response) {
        try {
          backendResponse = JSON.stringify(error.response.data);
        } finally {
          this.logger.error(
            `HTTP Error (${error.response.status}) on '${error.response.config.url}': ${error.message} (${backendResponse})`,
          );
        }
      }
github wireapp / wire-web-packages / packages / core / src / demo / sender.js View on Github external
(async () => {
  const CONVERSATION_ID = program.conversationId || process.env.WIRE_CONVERSATION_ID;
  const MESSAGE_TIMER = TimeUtil.TimeInMillis.SECOND * 5;

  const login = {
    clientType: ClientType.TEMPORARY,
    email: process.env.WIRE_EMAIL,
    password: process.env.WIRE_PASSWORD,
  };

  const backend = process.env.WIRE_BACKEND === 'staging' ? APIClient.BACKEND.STAGING : APIClient.BACKEND.PRODUCTION;
  const engine = new FileEngine(path.join(__dirname, '.tmp', 'sender'));
  await engine.init(undefined, {fileExtension: '.json'});

  const apiClient = new APIClient({store: engine, urls: backend});
  const account = new Account(apiClient);
  await account.login(login);
  await account.listen();
github wireapp / wire-web-packages / packages / api-client / src / tcp / ReconnectingWebsocket.ts View on Github external
export class ReconnectingWebsocket {
  private static readonly RECONNECTING_OPTIONS: Options = {
    WebSocket: typeof window !== 'undefined' ? WebSocket : NodeWebSocket,
    connectionTimeout: TimeUtil.TimeInMillis.SECOND * 4,
    debug: false,
    maxReconnectionDelay: TimeUtil.TimeInMillis.SECOND * 10,
    maxRetries: Infinity,
    minReconnectionDelay: TimeUtil.TimeInMillis.SECOND * 4,
    reconnectionDelayGrowFactor: 1.3,
  };

  private readonly logger: logdown.Logger;
  private socket?: RWS;
  private pingerId?: NodeJS.Timeout;
  private readonly PING_INTERVAL = TimeUtil.TimeInMillis.SECOND * 20;
  private hasUnansweredPing: boolean;

  private onOpen?: (event: Event) => void;
  private onMessage?: (data: string) => void;
  private onError?: (error: ErrorEvent) => void;
  private onClose?: (event: CloseEvent) => void;

  constructor(
    private readonly onReconnect: () => Promise,
    options: {
      pingInterval?: number;
    } = {},
  ) {
    this.logger = logdown('@wireapp/api-client/tcp/ReconnectingWebsocket', {
      logger: console,
      markdown: false,
github wireapp / wire-web-packages / packages / core / src / demo / sender.js View on Github external
async function sendAndDeleteMessage() {
    const deleteTextPayload = account.service.conversation.messageBuilder
      .createText(CONVERSATION_ID, 'Delete me!')
      .build();
    const {id: messageId} = await account.service.conversation.send(deleteTextPayload);

    const fiveSecondsInMillis = TimeUtil.TimeInMillis.SECOND * 5;
    setTimeout(async () => {
      await account.service.conversation.deleteMessageEveryone(CONVERSATION_ID, messageId);
    }, fiveSecondsInMillis);
  }
github wireapp / wire-web-packages / packages / api-client / src / tcp / ReconnectingWebsocket.ts View on Github external
export enum WEBSOCKET_STATE {
  CONNECTING = 0,
  OPEN = 1,
  CLOSING = 2,
  CLOSED = 3,
}

export enum PingMessage {
  PING = 'ping',
  PONG = 'pong',
}

export class ReconnectingWebsocket {
  private static readonly RECONNECTING_OPTIONS: Options = {
    WebSocket: typeof window !== 'undefined' ? WebSocket : NodeWebSocket,
    connectionTimeout: TimeUtil.TimeInMillis.SECOND * 4,
    debug: false,
    maxReconnectionDelay: TimeUtil.TimeInMillis.SECOND * 10,
    maxRetries: Infinity,
    minReconnectionDelay: TimeUtil.TimeInMillis.SECOND * 4,
    reconnectionDelayGrowFactor: 1.3,
  };

  private readonly logger: logdown.Logger;
  private socket?: RWS;
  private pingerId?: NodeJS.Timeout;
  private readonly PING_INTERVAL = TimeUtil.TimeInMillis.SECOND * 20;
  private hasUnansweredPing: boolean;

  private onOpen?: (event: Event) => void;
  private onMessage?: (data: string) => void;
  private onError?: (error: ErrorEvent) => void;