-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSimpleWebSocketMessagePlatformAdapter.hpp
More file actions
35 lines (26 loc) · 1.07 KB
/
Copy pathSimpleWebSocketMessagePlatformAdapter.hpp
File metadata and controls
35 lines (26 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
// Copyright © 2022 Michael Thornburgh
// SPDX-License-Identifier: MIT
#include "RTWebSocket.hpp"
#include "SimpleWebSocket.hpp"
namespace com { namespace zenomt { namespace rtws {
class SimpleWebSocketMessagePlatformAdapter : public IMessagePlatformAdapter, public Object {
public:
SimpleWebSocketMessagePlatformAdapter(std::shared_ptr<IStreamPlatformAdapter> platform);
bool init(std::shared_ptr<websock::SimpleWebSocket> websock);
Task onOpen;
Time getCurrentTime() override;
void notifyWhenWritable(const onwritable_f &onwritable) override;
void setOnReceiveBytesCallback(const onreceivebytes_f &onreceivebytes) override;
void setOnStreamDidCloseCallback(const Task &onstreamdidclose) override;
void doLater(const Task &task) override;
bool writeBytes(const void *bytes, size_t len) override;
void onClientClosed() override;
protected:
void onWebsockOpen();
void onWebsockError();
std::shared_ptr<IStreamPlatformAdapter> m_platform;
std::shared_ptr<websock::SimpleWebSocket> m_websock;
Task m_onstreamdidclose;
};
} } } // namespace com::zenomt::rtws