7 #ifndef CPPWAMP_INTERNAL_ASIOCONNECTOR_HPP
8 #define CPPWAMP_INTERNAL_ASIOCONNECTOR_HPP
11 #include "../codec.hpp"
12 #include "../error.hpp"
13 #include "../rawsockoptions.hpp"
14 #include "asioendpoint.hpp"
23 template <
typename TEstablisher>
24 class AsioConnector :
public AsioEndpoint<TEstablisher>
27 using Establisher = TEstablisher;
30 : Base(std::move(est)),
32 maxRxLength_(maxRxLength)
36 using Base = AsioEndpoint<TEstablisher>;
39 using Handshake =
typename Base::Handshake;
41 virtual void onEstablished()
override
43 Base::sendHandshake( Handshake().setCodecId(codecId_)
44 .setMaxLength(maxRxLength_) );
47 virtual void onHandshakeSent(Handshake)
override {Base::receiveHandshake();}
49 virtual void onHandshakeReceived(Handshake hs)
override
51 if (!hs.hasMagicOctet())
53 else if (hs.reserved() != 0)
55 else if (hs.codecId() == codecId_)
56 Base::complete(codecId_, hs.maxLengthInBytes(),
57 Handshake::byteLengthOf(maxRxLength_));
58 else if (hs.hasError())
59 Base::fail(hs.errorCode());
73 #endif // CPPWAMP_INTERNAL_ASIOCONNECTOR_HPP