more templates in WebSocketTransport
This commit is contained in:
parent
95eab59c08
commit
543c2086b2
@ -326,9 +326,10 @@ namespace ix
|
|||||||
return _txbuf.empty();
|
return _txbuf.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Iterator>
|
||||||
void WebSocketTransport::appendToSendBuffer(const std::vector<uint8_t>& header,
|
void WebSocketTransport::appendToSendBuffer(const std::vector<uint8_t>& header,
|
||||||
std::string::const_iterator begin,
|
Iterator begin,
|
||||||
std::string::const_iterator end,
|
Iterator end,
|
||||||
uint64_t message_size,
|
uint64_t message_size,
|
||||||
uint8_t masking_key[4])
|
uint8_t masking_key[4])
|
||||||
{
|
{
|
||||||
@ -750,8 +751,9 @@ namespace ix
|
|||||||
return static_cast<unsigned>(seconds);
|
return static_cast<unsigned>(seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
WebSocketSendInfo WebSocketTransport::sendData(wsheader_type::opcode_type type,
|
WebSocketSendInfo WebSocketTransport::sendData(wsheader_type::opcode_type type,
|
||||||
const std::string& message,
|
const T& message,
|
||||||
bool compress,
|
bool compress,
|
||||||
const OnProgressCallback& onProgressCallback)
|
const OnProgressCallback& onProgressCallback)
|
||||||
{
|
{
|
||||||
@ -764,8 +766,8 @@ namespace ix
|
|||||||
size_t wireSize = message.size();
|
size_t wireSize = message.size();
|
||||||
bool compressionError = false;
|
bool compressionError = false;
|
||||||
|
|
||||||
std::string::const_iterator message_begin = message.begin();
|
auto message_begin = message.begin();
|
||||||
std::string::const_iterator message_end = message.end();
|
auto message_end = message.end();
|
||||||
|
|
||||||
if (compress)
|
if (compress)
|
||||||
{
|
{
|
||||||
@ -859,10 +861,11 @@ namespace ix
|
|||||||
return WebSocketSendInfo(success, compressionError, payloadSize, wireSize);
|
return WebSocketSendInfo(success, compressionError, payloadSize, wireSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Iterator>
|
||||||
bool WebSocketTransport::sendFragment(wsheader_type::opcode_type type,
|
bool WebSocketTransport::sendFragment(wsheader_type::opcode_type type,
|
||||||
bool fin,
|
bool fin,
|
||||||
std::string::const_iterator message_begin,
|
Iterator message_begin,
|
||||||
std::string::const_iterator message_end,
|
Iterator message_end,
|
||||||
bool compress)
|
bool compress)
|
||||||
{
|
{
|
||||||
uint64_t message_size = static_cast<uint64_t>(message_end - message_begin);
|
uint64_t message_size = static_cast<uint64_t>(message_end - message_begin);
|
||||||
@ -1055,7 +1058,7 @@ namespace ix
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no close code/reason set
|
// no close code/reason set
|
||||||
sendData(wsheader_type::CLOSE, "", compress);
|
sendData(wsheader_type::CLOSE, std::string(""), compress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,15 +239,17 @@ namespace ix
|
|||||||
bool sendOnSocket();
|
bool sendOnSocket();
|
||||||
bool receiveFromSocket();
|
bool receiveFromSocket();
|
||||||
|
|
||||||
|
template<class T>
|
||||||
WebSocketSendInfo sendData(wsheader_type::opcode_type type,
|
WebSocketSendInfo sendData(wsheader_type::opcode_type type,
|
||||||
const std::string& message,
|
const T& message,
|
||||||
bool compress,
|
bool compress,
|
||||||
const OnProgressCallback& onProgressCallback = nullptr);
|
const OnProgressCallback& onProgressCallback = nullptr);
|
||||||
|
|
||||||
|
template<class Iterator>
|
||||||
bool sendFragment(wsheader_type::opcode_type type,
|
bool sendFragment(wsheader_type::opcode_type type,
|
||||||
bool fin,
|
bool fin,
|
||||||
std::string::const_iterator begin,
|
Iterator begin,
|
||||||
std::string::const_iterator end,
|
Iterator end,
|
||||||
bool compress);
|
bool compress);
|
||||||
|
|
||||||
void emitMessage(MessageKind messageKind,
|
void emitMessage(MessageKind messageKind,
|
||||||
@ -256,9 +258,11 @@ namespace ix
|
|||||||
const OnMessageCallback& onMessageCallback);
|
const OnMessageCallback& onMessageCallback);
|
||||||
|
|
||||||
bool isSendBufferEmpty() const;
|
bool isSendBufferEmpty() const;
|
||||||
|
|
||||||
|
template<class Iterator>
|
||||||
void appendToSendBuffer(const std::vector<uint8_t>& header,
|
void appendToSendBuffer(const std::vector<uint8_t>& header,
|
||||||
std::string::const_iterator begin,
|
Iterator begin,
|
||||||
std::string::const_iterator end,
|
Iterator end,
|
||||||
uint64_t message_size,
|
uint64_t message_size,
|
||||||
uint8_t masking_key[4]);
|
uint8_t masking_key[4]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user