YARP
Yet Another Robot Platform
WebSocketCarrier.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 WEBSOCKETCARRIER_H
7 #define WEBSOCKETCARRIER_H
8 
9 #include "WebSocket/WebSocket.h"
10 
11 #include <yarp/os/Carrier.h>
13 #include <yarp/os/LogComponent.h>
14 #include <yarp/os/LogStream.h>
15 #include <yarp/os/NetType.h>
16 #include <yarp/os/SizedWriter.h>
18 
19 #include <cstring>
20 
21 using namespace yarp::os;
22 using namespace yarp::os::impl;
23 
25  public TcpCarrier
26 {
27 public:
29 
30  Carrier* create() const override;
31 
32  std::string getName() const override;
33 
34  bool checkHeader(const Bytes& header) override;
35  void getHeader(Bytes& header) const override;
36  bool requireAck() const override;
37  bool isTextMode() const override;
38  bool supportReply() const override;
39  bool sendHeader(ConnectionState& proto) override;
40  bool expectReplyToHeader(ConnectionState& proto) override;
41  bool expectSenderSpecifier(ConnectionState& proto) override;
42  bool sendIndex(ConnectionState& proto, SizedWriter& writer) override;
43  bool expectIndex(ConnectionState& proto) override;
44  bool sendAck(ConnectionState& proto) override;
45  bool expectAck(ConnectionState& proto) override;
46  bool respondToHeader(ConnectionState& proto) override;
47  bool write(ConnectionState& proto, yarp::os::SizedWriter& writer) override;
48  bool canOffer() const override;
49 
50 private:
51  static constexpr size_t header_lenght {8};
52  WebSocket messageHandler;
53 };
54 
55 #endif // WEBSOCKETCARRIER_H
A simple abstraction for a block of bytes.
Definition: Bytes.h:25
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
Definition: Carrier.h:45
The basic state of a connection - route, streams in use, etc.
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:33
Communicating between two ports via TCP.
Definition: TcpCarrier.h:21
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:1098