From 72446df921f56c02d157e74b0188c12841a00a87 Mon Sep 17 00:00:00 2001 From: Chris Marsh Date: Thu, 13 Jul 2017 10:40:13 -0700 Subject: [PATCH] less stubby --- src/connection_unix.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/connection_unix.cpp b/src/connection_unix.cpp index d35e683..fbf5a23 100644 --- a/src/connection_unix.cpp +++ b/src/connection_unix.cpp @@ -1,13 +1,24 @@ #include "connection.h" +const int RpcVersion = 1; +const int NumFrames = 4; + +struct RpcConnectionUnix : public RpcConnection { + int pipe{-1}; + RpcMessageFrame frames[NumFrames]; + int nextFrame{0}; +}; + /*static*/ RpcConnection* RpcConnection::Create(const char* applicationId) { - return nullptr; + return new RpcConnectionUnix; } -/*static*/ void RpcConnection::Destroy(RpcConnection*&) +/*static*/ void RpcConnection::Destroy(RpcConnection*& c) { - + auto self = reinterpret_cast(c); + delete self; + c = nullptr; } void RpcConnection::Open() @@ -32,7 +43,10 @@ RpcMessageFrame* RpcConnection::Read() RpcMessageFrame* RpcConnection::GetNextFrame() { - return nullptr; + auto self = reinterpret_cast(this); + auto result = &(self->frames[self->nextFrame]); + self->nextFrame = (self->nextFrame + 1) % NumFrames; + return result; } void RpcConnection::WriteFrame(RpcMessageFrame* frame)