Page 1 of 1

trying to make a rest api service inside of csgo server

Posted: Wed Aug 30, 2017 8:16 am
by qwexvf
i don't know if its a good idea running a flask app inside my csgo server but if its possible how would i do that?
i was also looking at sanic framework which use asyncio. any ideas?

Thanks.

Re: trying to make a rest api service inside of csgo server

Posted: Wed Aug 30, 2017 10:41 am
by Ayuto
Yes, it's possible. iPlayer already did this with his MODT Player library:
viewtopic.php?f=38&t=1515

Re: trying to make a rest api service inside of csgo server

Posted: Wed Aug 30, 2017 6:52 pm
by iPlayer
Well, MOTDPlayer doesn't start web-server inside of the game server, this stuff is handled from outside.

What I'd suggest you to look is SP-CCP. This way you'll be able to connect a web-server with the game-server.

As for asyncio... It's possible to launch a uWSGI in asyncio+greenlet mode. Then you install Flask there, and with a tiny workaround it's possible to call awaitable coroutines from the regular Flask views. That can go very handy with websockets as the view won't be terminated immediately, but instead you can await for incoming data there.

If you were talking about Source.Python + asyncio, I've had an idea, but he haven't discussed that yet.

Re: trying to make a rest api service inside of csgo server

Posted: Thu Aug 31, 2017 12:58 am
by qwexvf
Why not directly make a web server instead of websockets??
edit:

or maybe i cloud just use redis to put everything i need as cache and then get it using any web app.
but what a bout pubsub thing? instead of websockets?

Re: trying to make a rest api service inside of csgo server

Posted: Thu Aug 31, 2017 3:22 pm
by iPlayer
SP-CCP doesn't involve websockets in any way.

Though connecting web-server with a game-server via websockets is also an option (that was proposed by Doldol).

There's no way a pure-pythonic web-server would handle the load as good as, say, nginx or Apache. Making the game-server responsible for the stuff it shouldn't be responsible (like serving static files) is not a way to go. Think of DDoS on your web port.

As for Redis, that's also an option for syncing the web- and game-servers. But I dunno, isn't that an overkill to use a pub-sub system just to exchange the data between two servers?