Free Matching Making Service on PC?
Hi guys, anyone know of a free match making service on the PC? of a fixed low cost solution?
Thanks!
-ddn
I'm afraid you'll have to give us a little more information than that.
I think that there are many free web-based matchmaking solutions that you might be able to use; almost all of them would run on a PC because a PC can run Apache / MySQL / PHP.
Or are you talking about UDP matchmaking for NAT punch-through?
I think that there are many free web-based matchmaking solutions that you might be able to use; almost all of them would run on a PC because a PC can run Apache / MySQL / PHP.
Or are you talking about UDP matchmaking for NAT punch-through?
Btw, here you go:
I just googled "python twisted tutorial" and spent 30 minutes writing some code. You run it by installing Python 2.6 and Twisted (both are free downloads), then simply:
python matcher.py
It will listen on port 54321, and accepts two kinds of commands (one line each):
LIST some-type-here some-name-here
MATCH some-substring-here
LIST puts a listing into the database under the appropriate type and name. MATCH searches for any listing that is newer than 2 minutes and contains some-substring-here within the "type" part of the listing. All arguments should be URL encoded, so spaces should become %20. Similarly, return values are also URL encoded.
Matches are returned one per line, of the form:
ip-address type-string name-string
No given command can be longer than 512 bytes.
[Edited by - hplus0603 on February 13, 2010 2:35:05 AM]
from twisted.internet import reactor, protocolfrom twisted.protocols import basicimport osimport sysimport timeimport urllibclass Session(object): def __init__(self, type, ip, name): self.ip = ip self.type = type self.name = name self.lasttime = time.time()# Matcher keeps a list of sessions, and can return a list of # sessions that match a given key and is not too oldclass Matcher(object): def __init__(self): self.sessions = {} def update(self, ip, type, name): self.sessions[ip] = Session(type, ip, name) def search(self, pattern): now = time.time() # do incremental clean-up of the session list, one item per query todel = None ret = [] for k in self.sessions.iteritems(): if k[1].lasttime > now - 120: if pattern in k[1].type: ret.append(k[1]) else: todel = k[0] if todel: del self.session[todel] return retmatcher = Matcher()class Protocol(basic.LineReceiver): def lineReceived(self, line): global matcher if len(line) > 512: # don't allow ridiculous sizes self.transport.loseConnection() return parts = line.split(" ") ret = ["error: no command given"] if len(parts) > 0: ret = ["error: unknown command '%s'" % (urllib.unquote(parts[0]).strip(),)] if len(parts) == 2: if parts[0] == 'MATCH': q = matcher.search(urllib.unquote(parts[1]).strip()) ret = ["found %d matches" % (len(q),)] for i in q: ret.append("%s %s %s" % (urllib.quote(str(i.ip.host)), urllib.quote(i.type), urllib.quote(i.name))) elif len(parts) == 3: if parts[0] == 'LIST': matcher.update(self.transport.getPeer(), urllib.unquote(parts[1]).strip(), urllib.unquote(parts[2]).strip()) ret = ["ok"] for l in ret: self.transport.write(l + "\r\n") self.transport.loseConnection()class Factory(protocol.ServerFactory): protocol = Protocoldef run(): reactor.listenTCP(54321, Factory()) reactor.run()if __name__ == "__main__": run()
I just googled "python twisted tutorial" and spent 30 minutes writing some code. You run it by installing Python 2.6 and Twisted (both are free downloads), then simply:
python matcher.py
It will listen on port 54321, and accepts two kinds of commands (one line each):
LIST some-type-here some-name-here
MATCH some-substring-here
LIST puts a listing into the database under the appropriate type and name. MATCH searches for any listing that is newer than 2 minutes and contains some-substring-here within the "type" part of the listing. All arguments should be URL encoded, so spaces should become %20. Similarly, return values are also URL encoded.
Matches are returned one per line, of the form:
ip-address type-string name-string
No given command can be longer than 512 bytes.
[Edited by - hplus0603 on February 13, 2010 2:35:05 AM]
Thanks hplus0603! Sorry for the lack of info, I'm not sure myself about the requirements. We were looking for some low cost solution for our casual games, for connecting PC <-> PC and maybe iPhone <-> PC or iPhone <-> iPhone game.
I'll look into Twisted, thanks for the heads up and the code ! :D
Thanks again!
-ddn
I'll look into Twisted, thanks for the heads up and the code ! :D
Thanks again!
-ddn
A question for you: What do you consider "low cost"?
And how many users do you expect to be using your application at the same time?
And how many users do you expect to be using your application at the same time?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement