discord-rpc/src/connection_unix.cpp

56 lines
991 B
C++
Raw Normal View History

2017-07-13 17:08:14 +00:00
#include "connection.h"
2017-07-13 17:40:13 +00: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 17:08:14 +00:00
/*static*/ RpcConnection* RpcConnection::Create(const char* applicationId)
{
2017-07-13 17:40:13 +00:00
return new RpcConnectionUnix;
2017-07-13 17:08:14 +00:00
}
2017-07-13 17:40:13 +00:00
/*static*/ void RpcConnection::Destroy(RpcConnection*& c)
2017-07-13 17:08:14 +00:00
{
2017-07-13 17:40:13 +00:00
auto self = reinterpret_cast<RpcConnectionUnix*&>(c);
delete self;
c = nullptr;
2017-07-13 17:08:14 +00: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 17:40:13 +00:00
auto self = reinterpret_cast<RpcConnectionUnix*>(this);
auto result = &(self->frames[self->nextFrame]);
self->nextFrame = (self->nextFrame + 1) % NumFrames;
return result;
2017-07-13 17:08:14 +00:00
}
void RpcConnection::WriteFrame(RpcMessageFrame* frame)
{
}