[?] Server interaction with mumble

Making or wanting help making your own asset? Check in here
BloodyDeed
Retired PR Developer
Posts: 4452
Joined: 2008-05-07 17:43

Re: [?] Server interaction with mumble

Post by BloodyDeed »

Is there any way to import this file into bf2 python?
Afaik urllib2 and urllib aren't available...
Image
AfterDune
Retired PR Developer
Posts: 17094
Joined: 2007-02-08 07:19

Re: [?] Server interaction with mumble

Post 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.
Image
AfterDune
Retired PR Developer
Posts: 17094
Joined: 2007-02-08 07:19

Re: [?] Server interaction with mumble

Post 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
Image
BloodyDeed
Retired PR Developer
Posts: 4452
Joined: 2008-05-07 17:43

Re: [?] Server interaction with mumble

Post by BloodyDeed »

Thanks alot, thats worth a try.
Image
sylent/shooter
Posts: 1963
Joined: 2009-04-10 18:48

Re: [?] Server interaction with mumble

Post 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!

Killing the enemy sylently
piepieonline
Retired PR Developer
Posts: 433
Joined: 2009-07-22 00:41

Re: [?] Server interaction with mumble

Post 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?
Image
AncientMan
Retired PR Developer
Posts: 5111
Joined: 2007-05-22 07:42

Re: [?] Server interaction with mumble

Post 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.
Image
piepieonline
Retired PR Developer
Posts: 433
Joined: 2009-07-22 00:41

Re: [?] Server interaction with mumble

Post 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?
Image
AfterDune
Retired PR Developer
Posts: 17094
Joined: 2007-02-08 07:19

Re: [?] Server interaction with mumble

Post by AfterDune »

Doesn't matter, it occurs as soon as the host retrieves data from the internet.
Image
piepieonline
Retired PR Developer
Posts: 433
Joined: 2009-07-22 00:41

Re: [?] Server interaction with mumble

Post 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.
Last edited by piepieonline on 2012-07-16 14:31, edited 2 times in total.
Image
Post Reply

Return to “PR:BF2 Community Modding”