Wrap up messageHandler, send(message)

This commit is contained in:
Alex Hultman
2018-10-30 03:01:19 +01:00
parent 292476366c
commit f2e2b7107a
5 changed files with 45 additions and 9 deletions
+22 -1
View File
@@ -3,13 +3,34 @@
#include "WebSocketData.h"
#include "WebSocketProtocol.h"
#include <string_view>
namespace uWS {
template <bool SSL>
template <bool SSL, bool isServer>
struct WebSocket {
private:
public:
void send(std::string_view message) {
// this path should use AsyncSocket with cork and everything
// format the response
char buf[100];
int writeLength = WebSocketProtocol<isServer, WebSocket<SSL, isServer>>::formatMessage(buf, message.data(), message.length(), uWS::OpCode::TEXT, message.length(), false);
us_socket_write((us_socket *) this, buf, writeLength, false);
}
// absolutely not public!
void init() {
// construct us