Page 2 of 2
Re: [?] Server interaction with mumble
Posted: 2012-02-14 17:33
by BloodyDeed
Is there any way to import this file into bf2 python?
Afaik urllib2 and urllib aren't available...
Re: [?] Server interaction with mumble
Posted: 2012-02-14 19:14
by AfterDune
You can get files from the interwebs using in-game Python, but my experience is that it stutters for a splitsecond when it does that. Perhaps nowadays that's no longer present, it's been a long while since I tried it.
Definitely worth a try.
If it still stutters, automatically let wget or something similar download the file for you and let the server read that instead. No hickups then.
Re: [?] Server interaction with mumble
Posted: 2012-02-14 19:17
by AfterDune
A small snippet from the global ban system from back then. It contains the code to read a webpage;
Code: Select all
def PostData(getVars):
global HOST, PATH
Debug("Entered PostData()")
d = time.strftime("%H:%M:%S")
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, 80))
s.setblocking(0)
s.settimeout(None)
s.send("GET %s HTTP/1.0\r\nHost: %s\r\n\r\n" % (PATH + getVars, HOST))
text = ""
while 1:
t = s.recv(1024)
if len(t) == 0:
break
text += t
s.close()
s = None
except:
Debug("Couldn't process the http request!")
if not text:
Debug("No text received?")
else:
text = str(text).split("#####")
if len(text) < 2:
Debug("Retrieved server data incorrect. Connection problems?")
else:
text = text[1]
Debug("Text received: " + text)
return text
Re: [?] Server interaction with mumble
Posted: 2012-02-14 21:09
by BloodyDeed
Thanks alot, thats worth a try.
Re: [?] Server interaction with mumble
Posted: 2012-02-15 00:10
by sylent/shooter
Thanks for the post Ancient it helps a lot even though I have no idea how json is implemented it was an interesting read. Hope this works and hope that there won't be any problems!
edit: is there anything that is opposite of wget? like auto upload because this looks like something that would help my idea for an online hacking/cheating directory!
Re: [?] Server interaction with mumble
Posted: 2012-02-15 13:29
by piepieonline
Yea, I would love to be able to poll the data rather than pull it down, simply for efficiencies sake..
I will look into the socket command, hopefully it works without stutter... If it stutters, I'll look at threading, then finally fall back to auto downloading the file.
Honestly, I want push based for the data for my stats system, its starting to annoy me that it doesn't appear possible to pull data...
sylent/shooter, you could just set up the same automated task, and run the upload script that way?
Re: [?] Server interaction with mumble
Posted: 2012-02-16 07:38
by AncientMan
Yeah, sockets doesn't work in BF2 python, since it can't by done async, so it will pause the server for a second or so when it gets the data

.
So, instead, made a client and server program and a module for AD Framework which does it all

. The client (on the bf2 server) downloads the data from the server (on the mumble server) on a schedule, and then the adf module checks if a player is in mumble a few minutes after they spawn in for the first time. If not, you can either kick them or warn an admin. Seems to work fine locally, but I'll get it tested properly over the next few days and then release it for server admins to put on their server
Only downside about this method is you need enough access on your bf2 server to be able to configure a schedule for an external process, but it's the only method that can be used to do this unfortunately.
Re: [?] Server interaction with mumble
Posted: 2012-02-16 09:53
by piepieonline
Yea, I have remote desktop access - setting this sort of thing up is no problem. It's annoying how its not portable :S
Hmm... Should I be seeing this pause in local/locked server games? Or is this only when more people are on the server?
Re: [?] Server interaction with mumble
Posted: 2012-02-16 11:25
by AfterDune
Doesn't matter, it occurs as soon as the host retrieves data from the internet.
Re: [?] Server interaction with mumble
Posted: 2012-02-16 12:18
by piepieonline
Interesting - I'm not seeing it at all, although I have only tested by myself for now.
Another fact that might be of consideration is that I'm only pulling the header and '[true]' or '[false]'...
EDIT: Ok, today I got others onto the server with me, and now I can see the stutter. It really only affects air assets, but yea, I will probably have to go the other route, which is a pain.