@@ -103,7 +103,7 @@ def info(self, addr: Address | None = None) -> ClientEventInfo:
103103
104104 """
105105 proto = self ._get_protocol (addr )
106- return self ._send_until (ClientEventInfo , proto .info , addr )
106+ return self ._send (ClientEventInfo , addr , proto .info )
107107
108108 def players (self , addr : Address | None = None ) -> ClientEventPlayers :
109109 """Send an A2S_PLAYER request and wait for a response.
@@ -125,7 +125,7 @@ def players(self, addr: Address | None = None) -> ClientEventPlayers:
125125
126126 """
127127 proto = self ._get_protocol (addr )
128- return self ._send_until (ClientEventPlayers , proto .players , addr )
128+ return self ._send (ClientEventPlayers , addr , proto .players )
129129
130130 def rules (self , addr : Address | None = None ) -> ClientEventRules :
131131 """Send an A2S_RULES request and wait for a response.
@@ -147,7 +147,7 @@ def rules(self, addr: Address | None = None) -> ClientEventRules:
147147
148148 """
149149 proto = self ._get_protocol (addr )
150- return self ._send_until (ClientEventRules , proto .rules , addr )
150+ return self ._send (ClientEventRules , addr , proto .rules )
151151
152152 @classmethod
153153 def from_addr (
@@ -255,11 +255,11 @@ def _create_protocol(self) -> A2SClientProtocol:
255255 """
256256 return A2SClientProtocol ()
257257
258- def _send_until (
258+ def _send (
259259 self ,
260260 t : Type [ClientEventT ],
261- request : Callable [[], ClientPacket ],
262261 addr : Address | None ,
262+ payload : Callable [[], ClientPacket ],
263263 ) -> ClientEventT :
264264 """Use the given request function to generate an outbound packet,
265265 and wait until the server responds with the given event type.
@@ -276,7 +276,7 @@ def _send_until(
276276 types = (t , ClientEventChallenge )
277277
278278 for _ in range (3 ):
279- self ._send (bytes (request ()), addr )
279+ self ._sendto (bytes (payload ()), addr )
280280 events = list (filter_type (types , self ._recv (addr )))
281281 if not events :
282282 # FIXME: not really a timeout, should be a custom exception
@@ -286,7 +286,7 @@ def _send_until(
286286
287287 raise ChallengeError ("Server responded with too many challenges" )
288288
289- def _send (self , data : bytes , addr : Address | None ) -> int :
289+ def _sendto (self , data : bytes , addr : Address | None ) -> int :
290290 if addr is not None :
291291 return self ._sock .sendto (data , addr )
292292 else :
@@ -327,7 +327,7 @@ def _receive_datagram(self, data: bytes, addr: Address | None) -> list[ClientEve
327327
328328 proto .receive_datagram (data )
329329 for packet in proto .packets_to_send ():
330- self ._send (bytes (packet ), addr )
330+ self ._sendto (bytes (packet ), addr )
331331
332332 return proto .events_received ()
333333
@@ -337,7 +337,7 @@ class A2SGoldsource(A2S):
337337
338338 def info (self , addr : Address | None = None ) -> ClientEventGoldsourceInfo : # type: ignore
339339 proto = self ._get_protocol (addr )
340- return self ._send_until (ClientEventGoldsourceInfo , proto .info , addr )
340+ return self ._send (ClientEventGoldsourceInfo , addr , proto .info )
341341
342342 def _create_protocol (self ) -> A2SGoldsourceClientProtocol :
343343 return A2SGoldsourceClientProtocol ()
0 commit comments