Skip to content

Commit

Permalink
feat: add 'close_connection' method in raknet_python
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Feb 22, 2024
1 parent a291fe8 commit a9468d8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/raknet/_raknet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class RakPeer:
offline_ping_response: bytes
def __init__(self) -> None:
...
def close_connection(self, target: SystemAddress, send_disconnection_notification: bool, ordering_channel: int = 0, disconnection_notification_priority: PacketPriority = PacketPriority.LOW_PRIORITY) -> None:
...
def connect(self, host: str, port: int, num_attempts: int = 6, attempt_interval_ms: int = 1000, timeout: int = 0) -> None:
...
def get_bound_address(self, index: int = 0) -> SystemAddress:
Expand All @@ -113,4 +115,9 @@ class RakPeer:
def num_connections(self) -> int:
...


def time() -> float:
...
def time_ms() -> int:
...
# @formatter:on # fmt: on
17 changes: 17 additions & 0 deletions src/raknet_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,23 @@ PYBIND11_MODULE(_raknet, m) {
py::arg("attempt_interval_ms") = 1000,
py::arg("timeout") = 0)

.def(
"close_connection",
[](RakNet::RakPeerInterface &self,
RakNet::SystemAddress &target,
bool send_disconnection_notification,
int ordering_channel,
PacketPriority disconnection_notification_priority) {
self.CloseConnection(target,
send_disconnection_notification,
static_cast<unsigned char>(ordering_channel & 0xff),
disconnection_notification_priority);
},
py::arg("target"),
py::arg("send_disconnection_notification"),
py::arg("ordering_channel") = 0,
py::arg("disconnection_notification_priority") = PacketPriority::LOW_PRIORITY)

.def("receive",
[](RakNet::RakPeerInterface &self) -> std::unique_ptr<Packet> {
auto *p = self.Receive();
Expand Down

0 comments on commit a9468d8

Please sign in to comment.