2017-07-13 18:08:14 +01:00
|
|
|
#include "connection.h"
|
|
|
|
|
2017-07-20 22:58:23 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
int GetProcessId()
|
|
|
|
{
|
|
|
|
return ::getpid();
|
|
|
|
}
|
|
|
|
|
2017-07-13 18:40:13 +01:00
|
|
|
const int RpcVersion = 1;
|
|
|
|
const int NumFrames = 4;
|
|
|
|
|
|
|
|
struct RpcConnectionUnix : public RpcConnection {
|
|
|
|
int pipe{-1};
|
|
|
|
RpcMessageFrame frames[NumFrames];
|
|
|
|
int nextFrame{0};
|
|
|
|
};
|
|
|
|
|
2017-07-13 18:08:14 +01:00
|
|
|
/*static*/ RpcConnection* RpcConnection::Create(const char* applicationId)
|
|
|
|
{
|
2017-07-13 18:40:13 +01:00
|
|
|
return new RpcConnectionUnix;
|
2017-07-13 18:08:14 +01:00
|
|
|
}
|
|
|
|
|
2017-07-13 18:40:13 +01:00
|
|
|
/*static*/ void RpcConnection::Destroy(RpcConnection*& c)
|
2017-07-13 18:08:14 +01:00
|
|
|
{
|
2017-07-13 18:40:13 +01:00
|
|
|
auto self = reinterpret_cast<RpcConnectionUnix*&>(c);
|
|
|
|
delete self;
|
|
|
|
c = nullptr;
|
2017-07-13 18:08:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void RpcConnection::Open()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RpcConnection::Close()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RpcConnection::Write(const void* data, size_t length)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
RpcMessageFrame* RpcConnection::Read()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
RpcMessageFrame* RpcConnection::GetNextFrame()
|
|
|
|
{
|
2017-07-13 18:40:13 +01:00
|
|
|
auto self = reinterpret_cast<RpcConnectionUnix*>(this);
|
|
|
|
auto result = &(self->frames[self->nextFrame]);
|
|
|
|
self->nextFrame = (self->nextFrame + 1) % NumFrames;
|
|
|
|
return result;
|
2017-07-13 18:08:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void RpcConnection::WriteFrame(RpcMessageFrame* frame)
|
|
|
|
{
|
|
|
|
}
|