21 #ifndef COMMON_RPC_RPCCHANNEL_H_
22 #define COMMON_RPC_RPCCHANNEL_H_
29 #include <google/protobuf/service.h>
32 #include <ola/util/SequenceNumber.h>
114 void CallMethod(
const google::protobuf::MethodDescriptor *method,
116 const google::protobuf::Message *request,
117 google::protobuf::Message *response,
139 typedef HASH_NAMESPACE::HASH_MAP_CLASS<int, class OutstandingResponse*>
142 std::auto_ptr<RpcSession> m_session;
144 std::auto_ptr<CloseCallback> m_on_close;
149 unsigned int m_buffer_size;
150 unsigned int m_expected_size;
151 unsigned int m_current_size;
152 HASH_NAMESPACE::HASH_MAP_CLASS<int, class OutstandingRequest*> m_requests;
153 ResponseMap m_responses;
157 bool SendMsg(RpcMessage *msg);
158 int AllocateMsgBuffer(
unsigned int size);
159 int ReadHeader(
unsigned int *version,
unsigned int *size)
const;
160 bool HandleNewMsg(uint8_t *buffer,
unsigned int size);
161 void HandleRequest(RpcMessage *msg);
162 void HandleStreamRequest(RpcMessage *msg);
166 void SendNotImplemented(
int msg_id);
170 void HandleResponse(RpcMessage *msg);
171 void HandleFailedResponse(RpcMessage *msg);
172 void HandleCanceledResponse(RpcMessage *msg);
173 void HandleNotImplemented(RpcMessage *msg);
175 void HandleChannelClose();
177 static const char K_RPC_RECEIVED_TYPE_VAR[];
178 static const char K_RPC_RECEIVED_VAR[];
179 static const char K_RPC_SENT_ERROR_VAR[];
180 static const char K_RPC_SENT_VAR[];
181 static const char *K_RPC_VARIABLES[];
182 static const char STREAMING_NO_RESPONSE[];
183 static const unsigned int INITIAL_BUFFER_SIZE = 1 << 11;
184 static const unsigned int MAX_BUFFER_SIZE = 1 << 20;
188 #endif // COMMON_RPC_RPCCHANNEL_H_