YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
WebSocketStream.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_WEBSOCKSTREAM_H
7#define YARP_WEBSOCKSTREAM_H
8
9#include "WebSocket/WebSocket.h"
10
13
14
19{
20public:
21 WebSocketStream(TwoWayStream* delegate);
22
23 ~WebSocketStream() override;
24
25 InputStream& getInputStream() override;
26 OutputStream& getOutputStream() override;
27
28 const yarp::os::Contact& getLocalAddress() const override;
29 const yarp::os::Contact& getRemoteAddress() const override;
30
31 void interrupt() override;
32
33 void close() override;
34
43 yarp::conf::ssize_t read(yarp::os::Bytes& bytesToRead) override;
44
53 void write(const yarp::os::Bytes& bytesToWrite) override;
54
55 bool isOk() const override;
56
57 void reset() override;
58
59 void beginPacket() override;
60 void endPacket() override;
61
62private:
63 yarp::os::TwoWayStream* delegate;
64 yarp::os::Contact local, remote;
66 size_t currentHead {0};
67
74 WebSocketFrameType getFrame(yarp::os::ManagedBytes& payload);
75
83 static void makeFrame(WebSocketFrameType frame_type,
84 const yarp::os::Bytes& payload,
86};
87
88#endif // YARP_WEBSOCKSTREAM_H
void reset() override
Reset the stream.
const yarp::os::Contact & getLocalAddress() const override
Get the address of the local side of the stream.
void beginPacket() override
Mark the beginning of a logical packet.
~WebSocketStream() override
void endPacket() override
Mark the end of a logical packet (see beginPacket).
void write(const yarp::os::Bytes &bytesToWrite) override
Write a block of bytes to the stream.
void interrupt() override
Interrupt the stream.
void close() override
Terminate the stream.
OutputStream & getOutputStream() override
Get an OutputStream to write to.
const yarp::os::Contact & getRemoteAddress() const override
Get the address of the remote side of the stream.
InputStream & getInputStream() override
Get an InputStream to read from.
bool isOk() const override
Check if the stream is ok or in an error state.
A simple abstraction for a block of bytes.
Definition Bytes.h:24
Represents how to reach a part of a YARP network.
Definition Contact.h:33
Simple specification of the minimum functions needed from input streams.
Definition InputStream.h:25
virtual int read()
Read and return a single byte.
InputStream()
Constructor.
An abstraction for a block of bytes, with optional responsibility for allocating/destroying that bloc...
Simple specification of the minimum functions needed from output streams.
virtual void write(char ch)
Write a single byte to the stream.
A stream which can be asked to perform bidirectional communication.
::ssize_t ssize_t
Definition numeric.h:86