// Copyright (c) 2009 Shardul Deo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// Author: Shardul Deo
//
// Protobufs needed for socket rpcs.

package protobuf.socketrpc;

option java_package = "com.googlecode.protobuf.socketrpc";
option java_outer_classname = "SocketRpcProtos";

message Request {

  // RPC service full name
  required string service_name = 1;
  
  // RPC method name
  required string method_name = 2;
  
  // RPC request proto
  required bytes request_proto = 3;
}

message Response {

  // RPC response proto
  optional bytes response_proto = 1;
  
  // Error, if any
  optional string error = 2;
  
  // Was callback invoked
  optional bool callback = 3 [default = false];
  
  // Error Reason
  optional ErrorReason error_reason = 4;
}

// Possible error reasons
// The server-side errors are returned in the response from the server.
// The client-side errors are returned by the client-side code when it doesn't 
// have a response from the server.
enum ErrorReason {

  // Server-side errors
  BAD_REQUEST_DATA = 0; // Server received bad request data
  BAD_REQUEST_PROTO = 1; // Server received bad request proto
  SERVICE_NOT_FOUND = 2; // Service not found on server
  METHOD_NOT_FOUND = 3; // Method not found on server
  RPC_ERROR = 4; // Rpc threw exception on server
  RPC_FAILED = 5; // Rpc failed on server
  
  // Client-side errors (these are returned by the client-side code)
  INVALID_REQUEST_PROTO = 6; // Rpc was called with invalid request proto
  BAD_RESPONSE_PROTO = 7; // Server returned a bad response proto
  UNKNOWN_HOST = 8; // Could not find supplied host
  IO_ERROR = 9; // I/O error while communicating with server
}
