My goal is restarting a match/round with certain parameters automatically. The command is to be given somewhere outside my server.
I tried websocket communication through lomond library.
Syntax: Select all
import json
from filters.players import PlayerIter
from lomond import WebSocket # pip install lomond
from cvars import ConVar
from messages import SayText2
from simple_settings import settings
from .utils import sdm_logger
WEBSOCKET_URL = 'wss://echo.websocket.org'
websocket = WebSocket(WEBSOCKET_URL)
def do_restart():
for player in PlayerIter('human'):
SayText2(f'WOW!!! RESTART MESSAGE CAME!!!').send(player.index)
print('!!!!!!!!! websocket message recieved !!!!!!!')
for event in websocket:
print(event)
if event.name == 'text':
response = json.loads(event.text)
if type(response) is dict \
and response.get('action') == 'restart' \
and response.get('server') == ConVar('hostname').get_string():
do_restart()
Establishing connection works fine. The bad thing is that lomond library coroutine stops any other CS:GO server process. CS:GO server thinks, that an infinite loop occured and reboots itself.
Is there any way to alter communication with websocket or is there any way to recieve such command outside? Thinking of requests library approach, but maybe any other option available?