C++ Client  0.0.0.0
C++ wrapper for Corelink DLL
CorelinkSendStream.h
Go to the documentation of this file.
1 
6 #ifndef CORELINKSENDSTREAM_H
7 #define CORELINKSENDSTREAM_H
8 
9 #include "CorelinkClasses.h"
10 
11 namespace Corelink {
12  inline SendStream::SendStream(const STREAM_ID& stream, int state, int streamRef) :
13  streamID(stream), state(state), streamRef(streamRef)
14  {}
15 
16  inline SendStream::SendStream(const StreamData& streamData) {
17  if ((streamData.state & Const::STREAM_STATE_SEND) > 0) {
18  streamID = streamData.streamID;
19  state = streamData.state;
20  streamRef = streamData.streamRef;
21  }
22  else {
23  streamID = STREAM_DEF;
24  state = Const::STREAM_STATE_NONE;
25  streamRef = -1;
26  }
27  }
28 
29  inline SendStream::SendStream(const SendStream& rhs) :
30  streamID(rhs.streamID), state(rhs.state), streamRef(rhs.streamRef)
31  {}
32 
33  inline SendStream::SendStream(SendStream&& rhs) {
34  std::swap(this->streamID, rhs.streamID);
35  std::swap(this->state, rhs.state);
36  std::swap(this->streamRef, rhs.streamRef);
37  }
38 
40  this->streamID = rhs.streamID;
41  this->state = rhs.state;
42  this->streamRef = rhs.streamRef;
43  return *this;
44  }
45 
46  inline SendStream::operator STREAM_ID() const {
47  return this->streamID;
48  }
49 
50  inline bool SendStream::send(const std::string& msg, const int& federationID) {
51  return CorelinkDLL::sendMsg(this->state, this->streamRef, this->streamID, federationID, msg.c_str(), (int) msg.size());
52  }
53 
54  inline bool SendStream::send(const std::string& msg, const rapidjson::Document& json, bool serverCheck, const int& federationID) {
55  rapidjson::StringBuffer buffer;
56  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
57  json.Accept(writer);
58  int len = (int) buffer.GetSize();
59  return CorelinkDLL::sendMsgJson(this->state, this->streamRef, this->streamID, federationID, msg.c_str(), (int)msg.size(), buffer.GetString(), len, serverCheck);
60  }
61 
62  inline bool SendStream::send(const char* msg, int msgLen, const int& federationID) {
63  return CorelinkDLL::sendMsg(this->state, this->streamRef, this->streamID, federationID, msg, msgLen);
64  }
65 
66  inline bool SendStream::send(const char* msg, int msgLen, const rapidjson::Document& json, bool serverCheck, const int& federationID) {
67  rapidjson::StringBuffer buffer;
68  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
69  json.Accept(writer);
70  int len = (int)buffer.GetSize();
71  return CorelinkDLL::sendMsgJson(this->state, this->streamRef, this->streamID, federationID, msg, msgLen, buffer.GetString(), len, serverCheck);
72  }
73 }
74 
75 #endif