Exemplo n.º 1
0
    def time_listener(self, message: IXPFile = None):
        sH = message.get_info("hours")
        sM = message.get_info("minutes")
        sS = message.get_info("seconds")

        iH = int(sH)
        iM = int(sM)
        iS = int(sS)

        needsDateUpdate = False

        if self.__hours == -1:
            needsDateUpdate = True

        if self.__hours != 0 and iH == 0:
            needsDateUpdate = True

        if needsDateUpdate:
            server = Networking.instance.get_server()
            con = ClockNetworking.instance.get_connection()
            request = IXPFile()
            request.set_network_function("com.projectgame.clock.clock.getdate")
            server.ixp_request_async(con, request, lambda ixpFile: self.__date_listener(ixpFile))

        self.__set_time(hours=iH, minutes=iM, seconds=iS)
Exemplo n.º 2
0
    def __date_listener(self, ixpFile: IXPFile):
        sY = ixpFile.get_info("year")
        sM = ixpFile.get_info("month")
        sD = ixpFile.get_info("day")
        sW = ixpFile.get_info("weekday")

        iY = int(sY)
        iM = int(sM)
        iD = int(sD)
        iW = int(sW)

        if iW == -1:
            iW = 6

        for listener in self.__dateCallbacks:
            listener(year=iY, month=iM, day=iD, weekday=iW)