trying to make a rest api service inside of csgo server

All other Source.Python topics and issues.
qwexvf
Junior Member
Posts: 14
Joined: Wed Mar 22, 2017 2:36 am
Location: Tokyo/Japan
Contact:

trying to make a rest api service inside of csgo server

Postby qwexvf » Wed Aug 30, 2017 8:16 am

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.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

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

Postby Ayuto » Wed Aug 30, 2017 10:41 am

Yes, it's possible. iPlayer already did this with his MODT Player library:
viewtopic.php?f=38&t=1515
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

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

Postby iPlayer » Wed Aug 30, 2017 6:52 pm

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.
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
qwexvf
Junior Member
Posts: 14
Joined: Wed Mar 22, 2017 2:36 am
Location: Tokyo/Japan
Contact:

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

Postby qwexvf » Thu Aug 31, 2017 12:58 am

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?
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

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

Postby iPlayer » Thu Aug 31, 2017 3:22 pm

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?
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 21 guests