Commit 9733a035 authored by Vít Kabele's avatar Vít Kabele

CloseConnection message added.

parent 9912dc88
......@@ -322,6 +322,51 @@ void instrument_class_response__free_unpacked
assert(message->base.descriptor == &instrument_class_response__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void close_connection__init
(CloseConnection *message)
{
static const CloseConnection init_value = CLOSE_CONNECTION__INIT;
*message = init_value;
}
size_t close_connection__get_packed_size
(const CloseConnection *message)
{
assert(message->base.descriptor == &close_connection__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t close_connection__pack
(const CloseConnection *message,
uint8_t *out)
{
assert(message->base.descriptor == &close_connection__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t close_connection__pack_to_buffer
(const CloseConnection *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &close_connection__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
CloseConnection *
close_connection__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (CloseConnection *)
protobuf_c_message_unpack (&close_connection__descriptor,
allocator, len, data);
}
void close_connection__free_unpacked
(CloseConnection *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &close_connection__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void client_message__init
(ClientMessage *message)
{
......@@ -838,7 +883,71 @@ const ProtobufCMessageDescriptor instrument_class_response__descriptor =
(ProtobufCMessageInit) instrument_class_response__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor client_message__field_descriptors[3] =
static const ProtobufCEnumValue close_connection__close_reason__enum_values_by_number[1] =
{
{ "FINISHED", "CLOSE_CONNECTION__CLOSE_REASON__FINISHED", 0 },
};
static const ProtobufCIntRange close_connection__close_reason__value_ranges[] = {
{0, 0},{0, 1}
};
static const ProtobufCEnumValueIndex close_connection__close_reason__enum_values_by_name[1] =
{
{ "FINISHED", 0 },
};
const ProtobufCEnumDescriptor close_connection__close_reason__descriptor =
{
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
"CloseConnection.CloseReason",
"CloseReason",
"CloseConnection__CloseReason",
"",
1,
close_connection__close_reason__enum_values_by_number,
1,
close_connection__close_reason__enum_values_by_name,
1,
close_connection__close_reason__value_ranges,
NULL,NULL,NULL,NULL /* reserved[1234] */
};
static const ProtobufCFieldDescriptor close_connection__field_descriptors[1] =
{
{
"reason",
1,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
offsetof(CloseConnection, reason),
&close_connection__close_reason__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned close_connection__field_indices_by_name[] = {
0, /* field[0] = reason */
};
static const ProtobufCIntRange close_connection__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor close_connection__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"CloseConnection",
"CloseConnection",
"CloseConnection",
"",
sizeof(CloseConnection),
1,
close_connection__field_descriptors,
close_connection__field_indices_by_name,
1, close_connection__number_ranges,
(ProtobufCMessageInit) close_connection__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor client_message__field_descriptors[4] =
{
{
"session_init_request",
......@@ -876,8 +985,21 @@ static const ProtobufCFieldDescriptor client_message__field_descriptors[3] =
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"close_connection",
4,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(ClientMessage, request_case),
offsetof(ClientMessage, close_connection),
&close_connection__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned client_message__field_indices_by_name[] = {
3, /* field[3] = close_connection */
2, /* field[2] = instrument_class_request */
1, /* field[1] = instrumentation_delivery */
0, /* field[0] = session_init_request */
......@@ -885,7 +1007,7 @@ static const unsigned client_message__field_indices_by_name[] = {
static const ProtobufCIntRange client_message__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 3 }
{ 0, 4 }
};
const ProtobufCMessageDescriptor client_message__descriptor =
{
......@@ -895,7 +1017,7 @@ const ProtobufCMessageDescriptor client_message__descriptor =
"ClientMessage",
"",
sizeof(ClientMessage),
3,
4,
client_message__field_descriptors,
client_message__field_indices_by_name,
1, client_message__number_ranges,
......
......@@ -22,6 +22,7 @@ typedef struct _InstrumentationDelivery InstrumentationDelivery;
typedef struct _InstrumentationAcceptConfirmation InstrumentationAcceptConfirmation;
typedef struct _InstrumentClassRequest InstrumentClassRequest;
typedef struct _InstrumentClassResponse InstrumentClassResponse;
typedef struct _CloseConnection CloseConnection;
typedef struct _ClientMessage ClientMessage;
typedef struct _ServerMessage ServerMessage;
......@@ -34,6 +35,10 @@ typedef enum _InstrumentClassResponse__InstrumentClassResult {
INSTRUMENT_CLASS_RESPONSE__INSTRUMENT_CLASS_RESULT__ERROR = 3
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(INSTRUMENT_CLASS_RESPONSE__INSTRUMENT_CLASS_RESULT)
} InstrumentClassResponse__InstrumentClassResult;
typedef enum _CloseConnection__CloseReason {
CLOSE_CONNECTION__CLOSE_REASON__FINISHED = 0
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(CLOSE_CONNECTION__CLOSE_REASON)
} CloseConnection__CloseReason;
/* --- messages --- */
......@@ -146,11 +151,25 @@ struct _InstrumentClassResponse
, INSTRUMENT_CLASS_RESPONSE__INSTRUMENT_CLASS_RESULT__CLASS_UNMODIFIED, (char *)protobuf_c_empty_string, {0,NULL} }
/*
* Notify server about closing connection
*/
struct _CloseConnection
{
ProtobufCMessage base;
CloseConnection__CloseReason reason;
};
#define CLOSE_CONNECTION__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&close_connection__descriptor) \
, CLOSE_CONNECTION__CLOSE_REASON__FINISHED }
typedef enum {
CLIENT_MESSAGE__REQUEST__NOT_SET = 0,
CLIENT_MESSAGE__REQUEST_SESSION_INIT_REQUEST = 1,
CLIENT_MESSAGE__REQUEST_INSTRUMENTATION_DELIVERY = 2,
CLIENT_MESSAGE__REQUEST_INSTRUMENT_CLASS_REQUEST = 3
CLIENT_MESSAGE__REQUEST_INSTRUMENT_CLASS_REQUEST = 3,
CLIENT_MESSAGE__REQUEST_CLOSE_CONNECTION = 4
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(CLIENT_MESSAGE__REQUEST)
} ClientMessage__RequestCase;
......@@ -165,6 +184,7 @@ struct _ClientMessage
SessionInitRequest *session_init_request;
InstrumentationDelivery *instrumentation_delivery;
InstrumentClassRequest *instrument_class_request;
CloseConnection *close_connection;
};
};
#define CLIENT_MESSAGE__INIT \
......@@ -331,6 +351,25 @@ InstrumentClassResponse *
void instrument_class_response__free_unpacked
(InstrumentClassResponse *message,
ProtobufCAllocator *allocator);
/* CloseConnection methods */
void close_connection__init
(CloseConnection *message);
size_t close_connection__get_packed_size
(const CloseConnection *message);
size_t close_connection__pack
(const CloseConnection *message,
uint8_t *out);
size_t close_connection__pack_to_buffer
(const CloseConnection *message,
ProtobufCBuffer *buffer);
CloseConnection *
close_connection__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void close_connection__free_unpacked
(CloseConnection *message,
ProtobufCAllocator *allocator);
/* ClientMessage methods */
void client_message__init
(ClientMessage *message);
......@@ -392,6 +431,9 @@ typedef void (*InstrumentClassRequest_Closure)
typedef void (*InstrumentClassResponse_Closure)
(const InstrumentClassResponse *message,
void *closure_data);
typedef void (*CloseConnection_Closure)
(const CloseConnection *message,
void *closure_data);
typedef void (*ClientMessage_Closure)
(const ClientMessage *message,
void *closure_data);
......@@ -412,6 +454,8 @@ extern const ProtobufCMessageDescriptor instrumentation_accept_confirmation__des
extern const ProtobufCMessageDescriptor instrument_class_request__descriptor;
extern const ProtobufCMessageDescriptor instrument_class_response__descriptor;
extern const ProtobufCEnumDescriptor instrument_class_response__instrument_class_result__descriptor;
extern const ProtobufCMessageDescriptor close_connection__descriptor;
extern const ProtobufCEnumDescriptor close_connection__close_reason__descriptor;
extern const ProtobufCMessageDescriptor client_message__descriptor;
extern const ProtobufCMessageDescriptor server_message__descriptor;
......
......@@ -61,12 +61,24 @@ message InstrumentClassResponse {
bytes classBytes = 3;
}
// Notify server about closing connection
message CloseConnection {
enum CloseReason {
FINISHED = 0;
}
CloseReason reason = 1;
}
// Pack together messages from client to simply distinguish them at the server side.
message ClientMessage {
oneof request {
SessionInitRequest session_init_request = 1;
InstrumentationDelivery instrumentation_delivery = 2;
InstrumentClassRequest instrument_class_request = 3;
CloseConnection close_connection = 4;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment