keepAlive method

dynamic keepAlive ()

Implementation

keepAlive() {
  if (this.server == null || !this.websockets || !this.connected) return;
  Timer.periodic(Duration(milliseconds: this.keepAlivePeriod), (Timer t) {
    this.wsKeepaliveTimeoutId = t;
    Map<String, dynamic> request = {
      "janus": "keepalive",
      "session_id": this.sessionId,
      "transaction": Janus.randomString(12)
    };
    if (this.token != null) request["token"] = token;
    if (this.apiSecret != null) request["apisecret"] = this.apiSecret;
    Janus.log(request.toString());
    this.ws.send(jsonEncode(request));
  });
}