Beispiel #1
0
 def __init__(self, site, uid):
     Session.__init__(self, site, uid)
     print 'create session'
     self.fd = mydownload.myDownload()
     self.notifyOnExpire(lambda: self.userExpired())
     self.lock = threading.Condition()
     self.queue = []
     reactor.callInThread(downloadThread, self.fd, self.lock, self.queue)
Beispiel #2
0
 def __init__(self,site,uid):
     Session.__init__(self,site,uid)
     print 'create session'
     self.fd = mydownload.myDownload()
     self.notifyOnExpire(lambda: self.userExpired())
     self.lock = threading.Condition()
     self.queue = []
     reactor.callInThread(downloadThread,self.fd,self.lock,self.queue)   
Beispiel #3
0
 def __init__(self, site, uid, **kw):
     Session.__init__(self, site, uid, **kw)
     self.in_room = None
     self.phonebook = IGameServer(-1).players
     name = 'anon-%s' % rndname(3,6)
     NamedComponentized.__init__(self, name)
     if not self.config.debug:
         self.sessionTimeout *= 60
    def __init__(self, *args, **kwargs):
        Session.__init__(self, *args, **kwargs)

        # Reference to connection object (Protocol instance)
        self.protocol = None

        # Synchronizing object for avoiding race condition on session
        self.lock = semaphore.Semaphore(1)

        # Output buffering
        self.transport = Transport(self.uid, self.lock)

        # Setup cleanup method on session expiration
        self.notifyOnExpire(lambda: HttpSession.on_expire(self))
Beispiel #5
0
    def __init__(self, *args, **kwargs):
        Session.__init__(self, *args, **kwargs)
        
        # Reference to connection object (Protocol instance)
        self.protocol = None
        
        # Synchronizing object for avoiding race condition on session
        self.lock = semaphore.Semaphore(1)

        # Output buffering
        self.transport = Transport(self.uid, self.lock)
                        
        # Setup cleanup method on session expiration
        self.notifyOnExpire(lambda: HttpSession.on_expire(self))
Beispiel #6
0
    def __init__(self, resource, Session, requestFactory=None, *args,
                 **kwargs):
        """"""
        server.Site.__init__(self, resource, requestFactory, *args, **kwargs)
        self.sessionFactory = Session.Factory
        Session._site = self

        self.sessions = Session.get_sessions()
Beispiel #7
0
    def __init__(self,
                 resource,
                 Session,
                 requestFactory=None,
                 *args,
                 **kwargs):
        """"""
        server.Site.__init__(self, resource, requestFactory, *args, **kwargs)
        self.sessionFactory = Session.Factory
        Session._site = self

        self.sessions = Session.get_sessions()
Beispiel #8
0
 def __init__(self, postpath, session=None):
     self.sitepath = []
     self.written = []
     self.finished = 0
     self.postpath = postpath
     self.prepath = []
     self.session = None
     self.protoSession = session or Session(0, self)
     self.args = {}
     self.outgoingHeaders = {}
     self.responseHeaders = Headers()
     self.responseCode = None
     self.headers = {}
     self._finishedDeferreds = []
Beispiel #9
0
 def __init__(self, postpath, session=None):
     self.sitepath = []
     self.written = []
     self.finished = 0
     self.postpath = postpath
     self.prepath = []
     self.session = None
     self.protoSession = session or Session(0, self)
     self.args = {}
     self.requestHeaders = Headers()
     self.responseHeaders = Headers()
     self.responseCode = None
     self._finishedDeferreds = []
     self._serverName = b"dummy"
     self.clientproto = b"HTTP/1.0"
Beispiel #10
0
 def sessionFactory(site, uid, reactor=None):
     s = Session(site, uid, reactor=reactor)
     s.sessionTimeout = session_length
     return s
Beispiel #11
0
 def sessionFactory(site, uid, reactor=None):
     s = Session(site, uid, reactor=reactor)
     s.sessionTimeout = session_length
     return s
Beispiel #12
0
 def __init__(self, site, uid, reactor=None):
     Session.__init__(self, site, uid, reactor=None)
     self.yuzuki_session_data = dict()
Beispiel #13
0
 def expire(self):
     log.msg("Player idle: %s" % self.name)
     self.leave()
     self.phonebook.pop(self.name)
     Session.expire(self)
Beispiel #14
0
    def render_POST(self, request):
        print '[WebServer][Post] ' + request.uri
        session = request.getSession()

        if request.uri == '/api/register':
            request.setHeader('content-type', 'application/json')
            data = request.content.getvalue()

            entries = len(TempData)
            loop = 0

            while loop != entries:
                Session = TempData[loop]
                if Session.keys()[0] == session.uid:
                    data2 = Session[session.uid]
                loop += 1

            if hasattr(session, 'username'):
                return '{ "status": "err", "code": "username", "message": "You have already an account!", "data": "null" }'

            try:
                username = data.split('username='******'&')[0]
                if len(username) == 0:
                    raise Exception
            except:
                return '{ "status": "err", "code": "username", "message": "' + "You must enter username!" + '", "data": "null" }'

            try:
                email = data.split('email=')[1].split('&')[0]
                if len(email) == 0:
                    raise Exception
            except:
                return '{ "status": "err", "code": "username", "message": "' + "You must enter email!" + '", "data": "null" }'

            try:
                password1 = data.split('password='******'&')[0]
                password2 = data.split('password2=')[1].split('&')[0]

                if len(password1) == 0:
                    raise Exception
                if len(password2) == 0:
                    raise Exception
            except:
                request.setHeader('content-type', 'application/json')
                return '{ "status": "err", "code": "password1", "message": "' + "You must enter both passwords!" + '", "data": "null" }'

            if password1 != password2:
                request.setHeader('content-type', 'application/json')
                return '{ "status": "err", "code": "password2", "message": "' + "Passwords you typed doesn't match!" + '", "data": "null" }'

            try:
                birthday = data.split('birthday=')[1]

                if len(birthday) == 0:
                    raise Exception
            except:
                return '{ "status": "err", "code": "birthday", "message": "' + "You didn't specified correct birthday date!" + '", "data": "null" }'

            try:
                RegisterUser(username, email, password1, birthday)
            except:
                return '{ "status": "err", "code": "username", "message": "' + "This username or email are already registered!" + '", "data": "null" }'

            AccountID = GetAccountID(username)

            try:
                pass
            except:
                print ConsoleColor(
                    'Warning'
                ) + "[WebServer][Register] Cannot register new hero!" + ConsoleColor(
                    'End')
            baseMSGFactionStats = data2.split('baseMSGFactionStats=')[1].split(
                '&')[0]
            baseMSGPersonaClassStats = data2.split(
                'baseMSGPersonaClassStats=')[1].split('&')[0]
            baseMSGAppearanceSkinToneStats = data2.split(
                'baseMSGAppearanceSkinToneStats=')[1].split('&')[0]
            haircolor_ui_name = data2.split('haircolor_ui_name=')[1].split(
                '&')[0]
            baseMSGAppearanceHairStyleStats = data2.split(
                'baseMSGAppearanceHairStyleStats=')[1].split('&')[0]
            facial_ui_name = data2.split('facial_ui_name=')[1].split('&')[0]
            nameCharacterText = data2.split('nameCharacterText=')[1]
            RegisterHero(AccountID, baseMSGFactionStats,
                         baseMSGPersonaClassStats,
                         baseMSGAppearanceSkinToneStats, haircolor_ui_name,
                         baseMSGAppearanceHairStyleStats, facial_ui_name,
                         nameCharacterText)
            TempData.remove(Session)
            print ConsoleColor(
                'Success'
            ) + '[WebServer] Successfully registered new user! (' + username + ')' + ConsoleColor(
                'End')
            session.username = username
            return '{ "status": "ok", "data": {"redirect": "/api/GetSession?username='******'&password='******'"}, "message": "' + "Hello" + username + "!" + '" }'

        if request.uri == '/api/login':
            request.setHeader('content-type', 'application/json')
            data = request.content.getvalue()

            if hasattr(session, 'username'):
                return '{ "status": "err", "code": "username", "message": "You are already loggedom!", "data": "null" }'

            try:
                if len(data.split('&')[0].split('username='******'&')[0].split('username='******'content-type', 'application/json')
                return '{ "status": "err", "code": "username", "message": "' + "You must enter username!" + '", "data": "null" }'

            try:
                if len(data.split('&')[1].split('password='******'&')[1].split('password='******'content-type', 'application/json')
                return '{ "status": "err", "code": "password", "message": "' + "You must enter password!" + '", "data": "null" }'

            account = LoginUser(username)

            if account == None:
                return '{ "status": "err", "code": "username", "message": "' + "User not found!" + '", "data": "null" }'

            if account[1] == username and account[3] == password:
                print ConsoleColor(
                    'Success'
                ) + '[WebServer] User ' + username + ' successfully logged in!' + ConsoleColor(
                    'End')
                session.username = username
                return '{ "status": "ok", "data": {"redirect": "/api/GetSession?username='******'&password='******'"}, "message": "' + "Hello" + username + "!" + '" }'

        if request.uri == '/Register':
            file_handler = open('Web/Register.html', 'rb')
            response = file_handler.read()
            TempData.append({session.uid: request.content.getvalue()})
            file_handler.close()
            return response
Beispiel #15
0
def longTimeoutSession(*args, **kwargs):
    session = Session(*args, **kwargs)
    session.sessionTimeout = 36000
    return session
Beispiel #16
0
 def __init__(self, site, uid, reactor=None):
     Session.__init__(self, site, uid, reactor=None)
     self.yuzuki_session_data = dict()