Skip to content

Commit

Permalink
feat: add binding for ping method in RakPeer
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Feb 19, 2024
1 parent 8804956 commit 9b17f1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/raknet/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class RakPeer:
...
def get_bound_address(self, index: int = 0) -> SystemAddress:
...
def ping(self, host: str, port: int, only_reply_on_accepting_connections: bool = False) -> bool:
...
def receive(self) -> Packet:
...
def send(self, data: bytes, priority: PacketPriority, reliability: PacketReliability, ordering_channel: int, address: SystemAddress, force_receipt_num: int = 0) -> int:
Expand Down
9 changes: 9 additions & 0 deletions src/raknet_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ PYBIND11_MODULE(raknet_python, m) {
py::arg("ordering_channel") = 0,
py::arg("disconnection_notification_priority") = PacketPriority::LOW_PRIORITY)

.def(
"ping",
[](RakNet::RakPeerInterface &self, const std::string &host, unsigned short port, bool flag) {
return self.Ping(host.c_str(), port, flag);
},
py::arg("host"),
py::arg("port"),
py::arg("only_reply_on_accepting_connections") = false)

.def("get_bound_address", &RakNet::RakPeerInterface::GetMyBoundAddress, py::arg("index") = 0)

.def_property_readonly("active", &RakNet::RakPeerInterface::IsActive)
Expand Down

0 comments on commit 9b17f1a

Please sign in to comment.