All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage Maven / Gradle / Ivy

There is a newer version: 2.15.3
Show newest version
package org.whispersystems.signalservice.api.messages.calls;

import org.whispersystems.libsignal.util.guava.Optional;

import java.util.LinkedList;
import java.util.List;

public class SignalServiceCallMessage {

  private final Optional           offerMessage;
  private final Optional          answerMessage;
  private final Optional          hangupMessage;
  private final Optional            busyMessage;
  private final Optional> iceUpdateMessages;

  private SignalServiceCallMessage(Optional offerMessage,
                                   Optional answerMessage,
                                   Optional> iceUpdateMessages,
                                   Optional hangupMessage,
                                   Optional busyMessage)
  {
    this.offerMessage      = offerMessage;
    this.answerMessage     = answerMessage;
    this.iceUpdateMessages = iceUpdateMessages;
    this.hangupMessage     = hangupMessage;
    this.busyMessage       = busyMessage;
  }

  public static SignalServiceCallMessage forOffer(OfferMessage offerMessage) {
    return new SignalServiceCallMessage(Optional.of(offerMessage),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.absent());
  }

  public static SignalServiceCallMessage forAnswer(AnswerMessage answerMessage) {
    return new SignalServiceCallMessage(Optional.absent(),
                                        Optional.of(answerMessage),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.absent());
  }

  public static SignalServiceCallMessage forIceUpdates(List iceUpdateMessages) {
    return new SignalServiceCallMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.of(iceUpdateMessages),
                                        Optional.absent(),
                                        Optional.absent());
  }

  public static SignalServiceCallMessage forIceUpdate(final IceUpdateMessage iceUpdateMessage) {
    List iceUpdateMessages = new LinkedList<>();
    iceUpdateMessages.add(iceUpdateMessage);

    return new SignalServiceCallMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.of(iceUpdateMessages),
                                        Optional.absent(),
                                        Optional.absent());
  }

  public static SignalServiceCallMessage forHangup(HangupMessage hangupMessage) {
    return new SignalServiceCallMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.of(hangupMessage),
                                        Optional.absent());
  }

  public static SignalServiceCallMessage forBusy(BusyMessage busyMessage) {
    return new SignalServiceCallMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.of(busyMessage));
  }


  public static SignalServiceCallMessage empty() {
    return new SignalServiceCallMessage(Optional.absent(),
                                        Optional.absent(),
                                        Optional.>absent(),
                                        Optional.absent(),
                                        Optional.absent());
  }

  public Optional> getIceUpdateMessages() {
    return iceUpdateMessages;
  }

  public Optional getAnswerMessage() {
    return answerMessage;
  }

  public Optional getOfferMessage() {
    return offerMessage;
  }

  public Optional getHangupMessage() {
    return hangupMessage;
  }

  public Optional getBusyMessage() {
    return busyMessage;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy