class NotificaitonServer(object):
    """docstring for NotificaitonServer"""

    notifications = []

    def __init__(self, name, app):
        super(NotificaitonServer, self).__init__()
        self.name = name
        self.app = app

    def startServer(self):
        self.server = QLocalServer()
        self.server.listen(self.name)
        self.server.newConnection.connect(self.connected)
        pass

    def connected(self):
        # print("conncted!")
        if self.server.hasPendingConnections():
            self.conn = self.server.nextPendingConnection()
            # print(type(self.conn))
            self.conn.readyRead.connect(self.received)
            pass
        pass

    def received(self):
        # print("received!")
        content = self.conn.readAll()
        # print()
        self.notifications = [w for w in self.notifications if w.isVisible()]
        # print(len(self.notifications))
        for w in self.notifications:
            w.moveDown()
            pass

        payload = json.loads(bytes(content).decode("utf-8"))
        no = notification.NotifyOnce(payload)

        self.notifications.append(no)
        # ret = app.exec_()
        # print("app able to exit")
        # sys.exit(ret)
        pass