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;
Export variables on the http server.
A container for the exported variables.
Definition ExportMap.h:324
SequenceNumber, this ensures that we increment the sequence number whenever we go to use it.
Definition SequenceNumber.h:30
A 0 argument callback which deletes itself after it's run.
Definition Callback.h:141
A 1 argument callback which deletes itself after it's run.
Definition Callback.h:1004
Definition ExportMap.h:242
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
Definition RpcChannel.cpp:61
The RPC channel used to communicate between the client and the server. This implementation runs over ...
Definition RpcChannel.h:51
RpcSession * Session()
Return the RpcSession associated with this channel.
Definition RpcChannel.cpp:276
void RequestComplete(class OutstandingRequest *request)
Invoked by the RPC completion handler when the server side response is ready.
Definition RpcChannel.cpp:259
~RpcChannel()
Destructor.
Definition RpcChannel.cpp:138
SingleUseCallback1< void, class RpcSession * > CloseCallback
The callback to run when the channel is closed.
Definition RpcChannel.h:59
static const unsigned int PROTOCOL_VERSION
the RPC protocol version.
Definition RpcChannel.h:136
void CallMethod(const google::protobuf::MethodDescriptor *method, class RpcController *controller, const google::protobuf::Message *request, google::protobuf::Message *response, SingleUseCallback0< void > *done)
Invoke an RPC method on this channel.
Definition RpcChannel.cpp:205
void SetChannelCloseHandler(CloseCallback *callback)
Set the Callback to be run when the channel fails. The callback will be invoked if the descriptor is ...
Definition RpcChannel.cpp:201
RpcChannel(RpcService *service, ola::io::ConnectedDescriptor *descriptor, ExportMap *export_map=NULL)
Create a new RpcChannel.
Definition RpcChannel.cpp:109
bool PendingRPCs() const
Check if there are any pending RPCs on the channel. Pending RPCs are those where a request has been s...
Definition RpcChannel.h:91
void DescriptorReady()
Called when new data arrives on the descriptor.
Definition RpcChannel.cpp:142
void SetService(RpcService *service)
Set the Service to use to handle incoming requests.
Definition RpcChannel.h:83
A RpcController object is passed every time an RPC is invoked and is used to indicate the success or ...
Definition RpcController.h:42
Definition RpcService.h:35
Represents the RPC session between a client and server.
Definition RpcSession.h:45
The namespace containing all OLA symbols.
Definition Credentials.cpp:44