// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// **** DO NOT EDIT - this file was automatically generated. ****
syntax = "proto3";

package cast.web;

option optimize_for = LITE_RUNTIME;

message Message {
  oneof message_type {
    MessageRequest request = 1;
    MessageResponse response = 2;
    MessagePortStatus status = 3;
  }

  MessageChannelDescriptor channel = 4;
}

message MessageChannelDescriptor {
  uint32 channel_id = 1;
}

message MessageRequest {
  string data = 1;
  repeated MessagePortDescriptor ports = 2;
}

message MessageResponse {
  bool result = 1;
}

// MessagePortDescriptor is used to transfer ownership of a port across the
// MessageChannel. After port transfer, Messages may be sent to and from the
// port by using same |channel|, which must be unique to each entangled
// port pair. Pairs from Cast Core start with |channel_id| of 0x80000000 and
// increment by one for each pair; pairs generated by a runtime should start
// at 0x0 and increment by one to avoid collisions.
message MessagePortDescriptor {
  MessageChannelDescriptor channel = 1;
  MessagePortStatus peer_status = 2;
  uint32 sequence_number = 3;
}

message MessagePortStatus {
  enum Status {
    OK = 0;
    ERROR = 1;
    STARTED = 2;
  }

  Status status = 1;
}
