summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-12-21 20:31:07 -0800
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-12-21 20:31:07 -0800
commita46ed587d6bac9dcda69b56979b2f0398013b5ef (patch)
treeee32f4f30a228a3822fef6585c8c970bbb9ed808 /includes
parent9754372d5e4125bf5850d9cd3ae93d529efdef8d (diff)
Various tweaks and fixes to WebSockets, and receiving messages is now fully functional.
Diffstat (limited to 'includes')
-rw-r--r--includes/BWebSocket.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/includes/BWebSocket.h b/includes/BWebSocket.h
index 41e5a7d..a230a89 100644
--- a/includes/BWebSocket.h
+++ b/includes/BWebSocket.h
@@ -15,8 +15,12 @@ class WebSocketWorker : public StacklessTask {
protected:
WebSocketWorker(IO<Handle> socket, const String & url) : m_socket(new BStream(socket)) { m_name = String("WebSocket:") + url + "/" + m_socket->getName(); }
~WebSocketWorker() { free(m_payload); }
- private:
+ void disconnect() { m_socket->close(); }
+ virtual void receiveMessage(const uint8_t * msg, size_t len, bool binary) = 0;
+private:
void processMessage();
+ void processPing();
+ void processPong();
const char * getName() const { return m_name.to_charp(); }
void Do();
String m_name;
@@ -40,6 +44,14 @@ class WebSocketWorker : public StacklessTask {
bool m_firstFragment = true;
bool m_enforceServer = false;
bool m_enforceClient = false;
+ enum {
+ OPCODE_CONT = 0,
+ OPCODE_TEXT = 1,
+ OPCODE_BIN = 2,
+ OPCODE_CLOSE = 8,
+ OPCODE_PING = 9,
+ OPCODE_PONG = 10,
+ };
friend class WebSocketActionBase;
};