webXMPP

Check-in [c519c48b5b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Bringup, get/notify
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:c519c48b5b69c425c6f2098a74888d5a082f78a1d759b69dedbba03f8bf8c21a
User & Date: vandyswa@gmail.com 2017-06-27 20:23:13
Context
2017-06-28
21:00
Bring up initial message notification get check-in: 4dd13877ea user: vandyswa@gmail.com tags: master, trunk
2017-06-27
20:23
Bringup, get/notify check-in: c519c48b5b user: vandyswa@gmail.com tags: master, trunk
16:01
Cleanly exit check-in: c644b96a10 user: vandyswa@gmail.com tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to notified.py.

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180

181
182
183
184
185
186
187
188
189
190
191

192
193
194
195
196
197
198
    # Get our configuration
    f = open(os.getenv("HOME") + "/.config/notify.json", "r")
    d = json.loads(f.read())
    f.close()
    cfg = DictOb(d)

# Endless execution, notification client
def run(ipa, port):
    global cfg

    # Get a wrapper for our pong network connection
    conn = pong.Client(cfg.server, cfg.port, cfg.user, cfg.password)

    # Prep LEDs for use if possible
    setup_leds()
................................................................................

    # Watch DBus to turn LED's off when screen unlocks
    setup_dbus()

    # Params; we in particular need to know the server's
    #  intended timeout.
    while True:
        params = conn.pingpong(conn.msg("params", "get"))
        if params is not None:
            break
        time.sleep(pong.WAITNET)

    # This is how long they'll hold a notify/get pending before
    #  sending back a null result.
    # If we request one and don't hear back in this amount of
    #  time, we have a lost packet or something.
    tmo = params["timeout"]

    # Server loop

    while True:
        # Always yield for a second, so no matter
        #  what we never CPU spin hard.
        time.sleep(1)

        # Next round of notifications
        # Request events starting at this serial number
        pak = conn.msg("notify", "get", {
            "serial": serial,
            "detail": cfg.detail,
            "nmsg": cfg.nmsg})

        resp = conn.ping_pong(pak, tmo*1.1)

        # Failure
        if resp is None:
            time.sleep(pong.WAITNET)
            continue








|







 







|
|







|


>











>







147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
    # Get our configuration
    f = open(os.getenv("HOME") + "/.config/notify.json", "r")
    d = json.loads(f.read())
    f.close()
    cfg = DictOb(d)

# Endless execution, notification client
def run():
    global cfg

    # Get a wrapper for our pong network connection
    conn = pong.Client(cfg.server, cfg.port, cfg.user, cfg.password)

    # Prep LEDs for use if possible
    setup_leds()
................................................................................

    # Watch DBus to turn LED's off when screen unlocks
    setup_dbus()

    # Params; we in particular need to know the server's
    #  intended timeout.
    while True:
        pak = conn.pingpong(conn.msg("params", "get"))
        if pak is not None:
            break
        time.sleep(pong.WAITNET)

    # This is how long they'll hold a notify/get pending before
    #  sending back a null result.
    # If we request one and don't hear back in this amount of
    #  time, we have a lost packet or something.
    tmo = pak.inner["timeout"]

    # Server loop
    dest = (cfg.server, cfg.port)
    while True:
        # Always yield for a second, so no matter
        #  what we never CPU spin hard.
        time.sleep(1)

        # Next round of notifications
        # Request events starting at this serial number
        pak = conn.msg("notify", "get", {
            "serial": serial,
            "detail": cfg.detail,
            "nmsg": cfg.nmsg})
        pak.who = dest
        resp = conn.ping_pong(pak, tmo*1.1)

        # Failure
        if resp is None:
            time.sleep(pong.WAITNET)
            continue

Changes to udp.py.

76
77
78
79
80
81
82





















83
84
85
86
87
88
89
...
101
102
103
104
105
106
107

108


	    resp = self.conn.msg(uname, inner["pakseq"],
		"params", "got", { "timeout": TIMEOUT, })
	    self.conn.reply(pak, resp)
	    return

	log(" param unknown subop: " + subop)






















    # Dispatch the latest request
    def handle(self, pak):
	inner = pak.inner
	op = inner["op"]

	# Notifications
	if op == "notify":
................................................................................
    #  thread, interacting with the rest of the server
    #  via self.approot
    def run(self):
	while True:

	    # Next request
            pak = self.conn.next_msg()

            self.handle(pak)









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
|
>
>
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
...
122
123
124
125
126
127
128
129
130
131
132
	    resp = self.conn.msg(uname, inner["pakseq"],
		"params", "got", { "timeout": TIMEOUT, })
	    self.conn.reply(pak, resp)
	    return

	log(" param unknown subop: " + subop)

    # Notification operations
    def handle_notify(self, pak):
	inner = pak.inner
	subop = inner["subop"]

	# Look up account state for this user
	approot = self.approot
	uname = pak.outer["user"]
	user = approot.users.get(uname)
	if user is None:
	    # Start user on first use
	    if not approot.start_user(uname):
		log(" can't start user " + uname)
		return

	# Get next notification(s)
	if subop == "get":
	    pdb.set_trace()

	log(" notify unknown subop: " + subop)

    # Dispatch the latest request
    def handle(self, pak):
	inner = pak.inner
	op = inner["op"]

	# Notifications
	if op == "notify":
................................................................................
    #  thread, interacting with the rest of the server
    #  via self.approot
    def run(self):
	while True:

	    # Next request
            pak = self.conn.next_msg()
	    try:
		self.handle(pak)
	    except:
		log(" bad packet")