syntax = "proto3";

package Aurora.Proto.Events;

import "Proto/general.proto";
import "Proto/party.proto";

service RemoteEventService {
    //Party Service
    rpc GetEvents(EventsRequest) returns (stream BaseEvent) {};
    rpc SubscribeToEvents(SubscribeRequest) returns(SubscriptionResponse);
    rpc UnsubscribeFromEvents(UnsubscribeRequest) returns (SubscriptionResponse);
    rpc UnsubscribeFromAll(UnsubscribeAllRequest) returns (SubscriptionResponse);
}

message EventsRequest {
    string clientId = 1;
}

/* Subscription messages */
message SubscribeRequest {
    repeated EventType eventTypes = 1;
    string clientId = 2;
}

message UnsubscribeRequest {
    repeated EventType eventTypes = 1;
    string clientId = 2;
}

message UnsubscribeAllRequest {
    string clientId = 1;
}

message SubscriptionResponse {
    bool successful = 1;
}

/* Event Types */
enum EventType {
    PartyMemberJoined = 0;
    PartyMemberLeft = 1;
    MediaPlaying = 2;
    MediaStopped = 3;
}
message BaseEvent {
    EventType eventType = 1;
    string clientKey = 2;
    
    oneof derivedEvent {
        PartyMemberJoinedEvent partyMemberJoinedEvent = 3;
        PartyMemberLeftEvent partyMemberLeftEvent = 4;
        NewMediaPlayingEvent newMediaPlayingEvent = 5;
        MediaPausedEvent mediaPausedEvent = 6;
        MediaResumedEvent mediaResumedEvent = 7;
    }
}

message NewMediaPlayingEvent {
    Aurora.Proto.Party.RemoteMediaData media = 1;
}

message MediaResumedEvent {
    Aurora.Proto.General.Empty empty = 1;
}

message MediaPausedEvent {
    Aurora.Proto.General.Empty empty = 1;
}

message PartyMemberJoinedEvent {
    Aurora.Proto.Party.PartyMember member = 1;
}

message PartyMemberLeftEvent {
    Aurora.Proto.Party.PartyMember member = 1;
}