// Medea's gRPC callback server schema.

syntax = "proto3";

package callback;

// Service for receiving callbacks from Medea media server.
service Callback {
  /// Fires when a certain callback event happens on Medea media server.
  rpc OnEvent (Request) returns (Response);
}

// Request with a fired callback event and some meta information.
message Request {
  // FID (Full ID) of the element that event was occurred with.
  string fid = 1;
  // Time of event occurring.
  string at = 2;

  // Occurred callback event.
  oneof event {
    OnJoin on_join = 3;
    OnLeave on_leave = 4;
  }
}

// Empty response of the Callback service.
//
// We don't use 'google.protobuf.Empty' to be able to add
// some fields (if necessary) in the future.
message Response {}

// Event that fires when Member joins a Room.
message OnJoin {}

// Event that fires when Member leaves its Room.
message OnLeave {
  // Reason of why Member leaves the Room.
  Reason reason = 1;

  enum Reason {
    // Member was normally disconnected.
    DISCONNECTED = 0;

    // Connection with Member was lost.
    LOST_CONNECTION = 1;

    // Member was forcibly disconnected by server.
    KICKED = 2;

    // Medea media server is shutting down.
    SERVER_SHUTDOWN = 3;
  }
}
