예제 #1
0
    def disconnect(self, sock):
        """Handles socket disconnections"""

        hfoslog("[CM] Disconnect ", sock)

        try:
            if sock in self._sockets:
                hfoslog("[CM] Getting socket", lvl=debug)
                sockobj = self._sockets[sock]
                hfoslog("[CM] Getting clientuuid", lvl=debug)
                clientuuid = sockobj.clientuuid
                hfoslog("[CM] getting useruuid", lvl=debug)
                useruuid = self._clients[clientuuid].useruuid

                hfoslog("[CM] Firing disconnect event", lvl=debug)
                self.fireEvent(clientdisconnect(clientuuid, self._clients[clientuuid].useruuid))

                hfoslog("[CM] Logging out relevant client", lvl=debug)
                if useruuid != None:
                    hfoslog("[CM] Client was logged in", lvl=debug)
                    try:
                        self._logoutclient(useruuid, clientuuid)
                        hfoslog("[CM] Client logged out", clientuuid)
                    except Exception as e:
                        hfoslog("[CM] Couldn't clean up logged in user! ", self._users[useruuid], e, type(e),
                                lvl=critical)
                hfoslog("[CM] Deleting Client (", self._clients.keys, ")", lvl=debug)
                del self._clients[clientuuid]
                hfoslog("[CM] Deleting Socket", lvl=debug)
                del self._sockets[sock]
        except Exception as e:
            hfoslog("[CM] Error during disconnect handling: ", e, type(e), lvl=critical)
예제 #2
0
    def _handleAuthenticationEvents(self, requestdata, requestaction, clientuuid, sock):
        if requestaction == "login":
            try:
                hfoslog("[CM] Login request")

                username = requestdata['username']
                password = requestdata['password']
                requestedclientuuid = requestdata['clientuuid']
                hfoslog("[CM] Auth request by ", username)

                self.fireEvent(authenticationrequest(username, password, clientuuid, requestedclientuuid, sock), "auth")
                return
            except Exception as e:
                hfoslog("[CM] Login failed: ", e, lvl=warn)
        elif requestaction == "logout":
            hfoslog("[CM] User logged out, refreshing client.")
            try:
                if clientuuid in self._clients:
                    client = self._clients[clientuuid]
                    if client.useruuid:
                        self._logoutclient(client.useruuid, clientuuid)
                    self.fireEvent(clientdisconnect(clientuuid))
                else:
                    hfoslog("[CM] Client is not connected!", lvl=warn)
            except Exception as e:
                hfoslog("[CM] Error during client logout: ", e, type(e), lvl=error)
예제 #3
0
    def _handleAuthenticationEvents(self, requestdata, requestaction,
                                    clientuuid, sock):
        if requestaction == "login":
            try:
                hfoslog("[CM] Login request")

                username = requestdata['username']
                password = requestdata['password']
                requestedclientuuid = requestdata['clientuuid']
                hfoslog("[CM] Auth request by ", username)

                self.fireEvent(
                    authenticationrequest(username, password, clientuuid,
                                          requestedclientuuid, sock), "auth")
                return
            except Exception as e:
                hfoslog("[CM] Login failed: ", e, lvl=warn)
        elif requestaction == "logout":
            hfoslog("[CM] User logged out, refreshing client.")
            try:
                if clientuuid in self._clients:
                    client = self._clients[clientuuid]
                    if client.useruuid:
                        self._logoutclient(client.useruuid, clientuuid)
                    self.fireEvent(clientdisconnect(clientuuid))
                else:
                    hfoslog("[CM] Client is not connected!", lvl=warn)
            except Exception as e:
                hfoslog("[CM] Error during client logout: ",
                        e,
                        type(e),
                        lvl=error)
예제 #4
0
    def disconnect(self, sock):
        """Handles socket disconnections"""

        hfoslog("[CM] Disconnect ", sock)

        try:
            if sock in self._sockets:
                hfoslog("[CM] Getting socket", lvl=debug)
                sockobj = self._sockets[sock]
                hfoslog("[CM] Getting clientuuid", lvl=debug)
                clientuuid = sockobj.clientuuid
                hfoslog("[CM] getting useruuid", lvl=debug)
                useruuid = self._clients[clientuuid].useruuid

                hfoslog("[CM] Firing disconnect event", lvl=debug)
                self.fireEvent(
                    clientdisconnect(clientuuid,
                                     self._clients[clientuuid].useruuid))

                hfoslog("[CM] Logging out relevant client", lvl=debug)
                if useruuid != None:
                    hfoslog("[CM] Client was logged in", lvl=debug)
                    try:
                        self._logoutclient(useruuid, clientuuid)
                        hfoslog("[CM] Client logged out", clientuuid)
                    except Exception as e:
                        hfoslog("[CM] Couldn't clean up logged in user! ",
                                self._users[useruuid],
                                e,
                                type(e),
                                lvl=critical)
                hfoslog("[CM] Deleting Client (",
                        self._clients.keys,
                        ")",
                        lvl=debug)
                del self._clients[clientuuid]
                hfoslog("[CM] Deleting Socket", lvl=debug)
                del self._sockets[sock]
        except Exception as e:
            hfoslog("[CM] Error during disconnect handling: ",
                    e,
                    type(e),
                    lvl=critical)