Esempio n. 1
0
    #host = "server1.saltrubber.com"
    #host = "127.0.0.1"
    host = "0.0.0.0"
    hostname = socket.gethostname() 
    port = 9001
    name = "Banana_Core_1"
    serverID = str(random.getrandbits(64))

    tcpsock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    tcpsock.bind((host,port))
    threads = []
    
    mmObject = MMObject()
    
    dbObj = ServiceDBPrime()
    dbObj.registerServerOnline(name,hostname+":"+str(port),0,serverID)
    
    #Retrieve player limit
    totalAllowedPlayers = dbObj.retrievePlayerLimit()
    print ("Total allowed players in this server %s",(totalAllowedPlayers))
    
    while True:
        tcpsock.listen(5)
        (clientsock,(ip,port)) = tcpsock.accept()
        lock = threading.RLock()
        newthread = ClientThread(ip,port,clientsock,mmObject,lock)
        newthread.start()
        threads.append(newthread)
        #Update threads count
        dbObj.updateServerOnline(len(threads),serverID)
# -*- coding: utf-8 -*-
import random

from ServiceDB import ServiceDBPrime,ServiceDBMinor,ServiceDBGame,ServiceDBQuestions

if __name__ == "__main__":
    
    #dbPrime
    host = "127.0.0.1"
    port = 9999
    name = "Banana_Core_1"
    serverID = str(random.getrandbits(64))
    dbObj = ServiceDBPrime()
    #dbObj.registerServerOnline(name,host,0,serverID)
    
    totalAllowedPlayers = dbObj.retrievePlayerLimit()
    print ("Total allowed players in this server ,%s",totalAllowedPlayers)
    
    le = 10031
    #dbObj.updateServerOnline(le,serverID)
    
    #dbObj.unregisterServerOnline(serverID)
    
    
    
    
    
    
    #dbMinor
    dbM = ServiceDBMinor()
    uid = "001"