DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
WebSocket.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "Common.h"
7#include "System/Object.h"
8#include "System/String.h"
13#include "System/Array.h"
14#include <cstdint>
15
16namespace DotNetDupe {
17 namespace System {
18 namespace Net {
19 namespace WebSockets {
20
23 enum class WebSocketState {
24 None = 0,
26 Open = 2,
29 Closed = 5,
31 };
32
41 class WebSocket : public virtual Object {
42 public:
46
48 DOTNETDUPE_API ~WebSocket() override;
49
53
57
62 DOTNETDUPE_API bool SendAsync(const String& message);
63
68 DOTNETDUPE_API bool SendBytes(const Array<uint8_t>& data);
69
74 DOTNETDUPE_API bool ReceiveText(String& outMessage);
75
77 DOTNETDUPE_API void Close();
78
83 DOTNETDUPE_API static String ComputeSecWebSocketAccept(const String& secWebSocketKey);
84
85 private:
86 class Impl;
87 SmartPointer<Impl> m_pImpl;
88 };
89
90 }
91 }
92 }
93}
Provides methods for creating, manipulating, searching, and sorting arrays.
Defines common cross-platform macros, export decorators, and fundamental types.
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition Common.h:20
Provides a re-entrant mutual exclusion primitive for thread synchronization.
Provides an RAII-style scoped lock wrapper around synchronization primitives.
Provides the underlying stream of data for network access.
Base object class for DotNetDupe mirroring .NET System.Object.
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
High-performance UTF-8 / UTF-16 string manipulation class mirroring .NET System.String.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition Array.h:29
void Close()
Transmits an RFC 6455 close frame (opcode 0x8) and marks the state as Closed.
bool SendBytes(const Array< uint8_t > &data)
Sends a complete binary message frame (opcode 0x2) to the remote peer.
bool SendAsync(const String &message)
Sends a complete UTF-8 text message frame (opcode 0x1) to the remote peer.
WebSocketState GetState() const
Gets the current operational state of the WebSocket.
static String ComputeSecWebSocketAccept(const String &secWebSocketKey)
Computes the RFC 6455 Sec-WebSocket-Accept handshake header from a client challenge key.
bool ReceiveText(String &outMessage)
Receives and decodes the next complete text message frame from the stream.
void SetState(WebSocketState state)
Sets the operational state of the WebSocket.
WebSocket(SmartPointer< Sockets::NetworkStream > pStream)
Constructs a WebSocket instance bound to the specified open network stream.
Supports all classes in the DotNetDupe class hierarchy.
Definition Object.h:18
A unified smart pointer that supports both unique and shared ownership semantics.
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition String.h:74
WebSocketState
Defines the operational states that a WebSocket connection can be in.
Definition WebSocket.h:23
@ Closed
The connection has cleanly closed.
Definition WebSocket.h:29
@ CloseSent
A close control frame was transmitted.
Definition WebSocket.h:27
@ Aborted
The connection was aborted or closed abruptly.
Definition WebSocket.h:30
@ Open
The connection is open and ready for sending/receiving frames.
Definition WebSocket.h:26
@ Connecting
The connection is negotiating the handshake.
Definition WebSocket.h:25
@ CloseReceived
A close control frame was received from the remote peer.
Definition WebSocket.h:28