-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
erase front dependency to bcos-boostssl
- Loading branch information
1 parent
7c69e64
commit 0f65fd8
Showing
27 changed files
with
460 additions
and
1,207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* Copyright (C) 2023 WeDPR. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* @file Message.h | ||
* @author: yujiechen | ||
* @date 2024-08-22 | ||
*/ | ||
#pragma once | ||
#include "Message.h" | ||
#include <bcos-boostssl/interfaces/MessageFace.h> | ||
namespace ppc::protocol | ||
{ | ||
// the wrapper for use boostssl service | ||
class P2PMessage : virtual public bcos::boostssl::MessageFace, public Message | ||
{ | ||
public: | ||
using Ptr = std::shared_ptr<P2PMessage>; | ||
P2PMessage() = default; | ||
~P2PMessage() override {} | ||
|
||
/// the overloaed implementation === | ||
uint16_t version() const override { return m_header->version(); } | ||
void setVersion(uint16_t version) override { m_header->setVersion(version); } | ||
uint16_t packetType() const override { return m_header->packetType(); } | ||
void setPacketType(uint16_t packetType) override { m_header->setPacketType(packetType); } | ||
std::string const& seq() const override { return m_header->traceID(); } | ||
void setSeq(std::string traceID) override { m_header->setTraceID(traceID); } | ||
uint16_t ext() const override { return m_header->ext(); } | ||
void setExt(uint16_t ext) override { m_header->setExt(ext); } | ||
|
||
bool isRespPacket() const override { return m_header->isRespPacket(); } | ||
void setRespPacket() override { m_header->setRespPacket(); } | ||
|
||
uint32_t length() const override { return Message::length(); } | ||
std::shared_ptr<bcos::bytes> payload() override { return Message::payload(); } | ||
void setPayload(std::shared_ptr<bcos::bytes> _payload) override | ||
{ | ||
Message::setPayload(std::move(_payload)); | ||
} | ||
// encode and return the {header, payload} | ||
virtual bool encode(bcos::boostssl::EncodedMsg& _encodedMsg) = 0; | ||
}; | ||
|
||
|
||
class P2PMessageBuilder : virtual public bcos::boostssl::MessageFaceFactory, public MessageBuilder | ||
{ | ||
public: | ||
using Ptr = std::shared_ptr<P2PMessageBuilder>; | ||
P2PMessageBuilder() = default; | ||
~P2PMessageBuilder() override = default; | ||
}; | ||
inline std::string printWsMessage(bcos::boostssl::MessageFace::Ptr const& _msg) | ||
{ | ||
if (!_msg) | ||
{ | ||
return "nullptr"; | ||
} | ||
std::ostringstream stringstream; | ||
stringstream << LOG_KV("rsp", _msg->isRespPacket()) << LOG_KV("traceID", _msg->seq()) | ||
<< LOG_KV("packetType", _msg->packetType()) << LOG_KV("length", _msg->length()) | ||
<< LOG_KV("ext", _msg->ext()); | ||
return stringstream.str(); | ||
} | ||
|
||
} // namespace ppc::protocol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
file(GLOB_RECURSE SRCS *.cpp) | ||
add_library(${PROTOCOL_TARGET} ${SRCS}) | ||
|
||
target_link_libraries(${PROTOCOL_TARGET} PUBLIC ${BCOS_BOOSTSSL_TARGET} ${CPU_FEATURES_LIB} jsoncpp_static) | ||
target_link_libraries(${PROTOCOL_TARGET} PUBLIC ${CPU_FEATURES_LIB} jsoncpp_static) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.