mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
This reverts commit 42eaeb92f0
.
This commit is contained in:
@@ -417,7 +417,7 @@ class CommonContext:
|
|||||||
|
|
||||||
async def send_msgs(self, msgs: typing.List[typing.Any]) -> None:
|
async def send_msgs(self, msgs: typing.List[typing.Any]) -> None:
|
||||||
""" `msgs` JSON serializable """
|
""" `msgs` JSON serializable """
|
||||||
if not self.server or self.server.socket.state != websockets.protocol.State.OPEN:
|
if not self.server or not self.server.socket.open or self.server.socket.closed:
|
||||||
return
|
return
|
||||||
await self.server.socket.send(encode(msgs))
|
await self.server.socket.send(encode(msgs))
|
||||||
|
|
||||||
|
@@ -324,7 +324,7 @@ class Context:
|
|||||||
|
|
||||||
# General networking
|
# General networking
|
||||||
async def send_msgs(self, endpoint: Endpoint, msgs: typing.Iterable[dict]) -> bool:
|
async def send_msgs(self, endpoint: Endpoint, msgs: typing.Iterable[dict]) -> bool:
|
||||||
if not endpoint.socket or endpoint.socket.state != websockets.protocol.State.OPEN:
|
if not endpoint.socket or not endpoint.socket.open:
|
||||||
return False
|
return False
|
||||||
msg = self.dumper(msgs)
|
msg = self.dumper(msgs)
|
||||||
try:
|
try:
|
||||||
@@ -339,7 +339,7 @@ class Context:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
async def send_encoded_msgs(self, endpoint: Endpoint, msg: str) -> bool:
|
async def send_encoded_msgs(self, endpoint: Endpoint, msg: str) -> bool:
|
||||||
if not endpoint.socket or endpoint.socket.state != websockets.protocol.State.OPEN:
|
if not endpoint.socket or not endpoint.socket.open:
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
await endpoint.socket.send(msg)
|
await endpoint.socket.send(msg)
|
||||||
@@ -355,7 +355,7 @@ class Context:
|
|||||||
async def broadcast_send_encoded_msgs(self, endpoints: typing.Iterable[Endpoint], msg: str) -> bool:
|
async def broadcast_send_encoded_msgs(self, endpoints: typing.Iterable[Endpoint], msg: str) -> bool:
|
||||||
sockets = []
|
sockets = []
|
||||||
for endpoint in endpoints:
|
for endpoint in endpoints:
|
||||||
if endpoint.socket and endpoint.socket.state == websockets.protocol.State.OPEN:
|
if endpoint.socket and endpoint.socket.open:
|
||||||
sockets.append(endpoint.socket)
|
sockets.append(endpoint.socket)
|
||||||
try:
|
try:
|
||||||
websockets.broadcast(sockets, msg)
|
websockets.broadcast(sockets, msg)
|
||||||
@@ -924,7 +924,7 @@ async def on_client_joined(ctx: Context, client: Client):
|
|||||||
"If your client supports it, "
|
"If your client supports it, "
|
||||||
"you may have additional local commands you can list with /help.",
|
"you may have additional local commands you can list with /help.",
|
||||||
{"type": "Tutorial"})
|
{"type": "Tutorial"})
|
||||||
if not any(isinstance(extension, PerMessageDeflate) for extension in client.socket.protocol.extensions):
|
if not any(isinstance(extension, PerMessageDeflate) for extension in client.socket.extensions):
|
||||||
ctx.notify_client(client, "Warning: your client does not support compressed websocket connections! "
|
ctx.notify_client(client, "Warning: your client does not support compressed websocket connections! "
|
||||||
"It may stop working in the future. If you are a player, please report this to the "
|
"It may stop working in the future. If you are a player, please report this to the "
|
||||||
"client's developer.")
|
"client's developer.")
|
||||||
@@ -2107,7 +2107,7 @@ class ServerCommandProcessor(CommonCommandProcessor):
|
|||||||
def _cmd_exit(self) -> bool:
|
def _cmd_exit(self) -> bool:
|
||||||
"""Shutdown the server"""
|
"""Shutdown the server"""
|
||||||
try:
|
try:
|
||||||
self.ctx.server.server.close()
|
self.ctx.server.ws_server.close()
|
||||||
finally:
|
finally:
|
||||||
self.ctx.exit_event.set()
|
self.ctx.exit_event.set()
|
||||||
return True
|
return True
|
||||||
@@ -2477,7 +2477,7 @@ async def auto_shutdown(ctx, to_cancel=None):
|
|||||||
await asyncio.wait_for(ctx.exit_event.wait(), ctx.auto_shutdown)
|
await asyncio.wait_for(ctx.exit_event.wait(), ctx.auto_shutdown)
|
||||||
|
|
||||||
def inactivity_shutdown():
|
def inactivity_shutdown():
|
||||||
ctx.server.server.close()
|
ctx.server.ws_server.close()
|
||||||
ctx.exit_event.set()
|
ctx.exit_event.set()
|
||||||
if to_cancel:
|
if to_cancel:
|
||||||
for task in to_cancel:
|
for task in to_cancel:
|
||||||
|
@@ -272,7 +272,7 @@ def run_server_process(name: str, ponyconfig: dict, static_server_data: dict,
|
|||||||
|
|
||||||
await ctx.server
|
await ctx.server
|
||||||
port = 0
|
port = 0
|
||||||
for wssocket in ctx.server.server.sockets:
|
for wssocket in ctx.server.ws_server.sockets:
|
||||||
socketname = wssocket.getsockname()
|
socketname = wssocket.getsockname()
|
||||||
if wssocket.family == socket.AF_INET6:
|
if wssocket.family == socket.AF_INET6:
|
||||||
# Prefer IPv4, as most users seem to not have working ipv6 support
|
# Prefer IPv4, as most users seem to not have working ipv6 support
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
colorama>=0.4.6
|
colorama>=0.4.6
|
||||||
websockets>=15.0.1
|
websockets>=13.0.1,<14
|
||||||
PyYAML>=6.0.2
|
PyYAML>=6.0.2
|
||||||
jellyfish>=1.1.0
|
jellyfish>=1.1.0
|
||||||
jinja2>=3.1.4
|
jinja2>=3.1.4
|
||||||
|
Reference in New Issue
Block a user