Rev 4 | Rev 6 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4 | Rev 5 | ||
---|---|---|---|
Line 83... | Line 83... | ||
83 | output = output + '<p><a href="javascript:_toggle_alarm(1)">Enable motion detection</a><span id="pleasewait"></span></p>' |
83 | output = output + '<p><a href="javascript:_toggle_alarm(1)">Enable motion detection</a><span id="pleasewait"></span></p>' |
84 | 84 | ||
85 | output = output + '<h2>Subscribers</h2>' |
85 | output = output + '<h2>Subscribers</h2>' |
86 | 86 | ||
87 | found_subs = 0 |
87 | found_subs = 0 |
88 | for x in g_subscribed[:]: |
88 | for subscriber in g_subscribed[:]: |
89 | if int(time.time()) > x[2]: |
89 | if int(time.time()) > subscriber[2]: |
90 | g_subscribed.remove(x) |
90 | g_subscribed.remove(subscriber) |
91 | else: |
91 | else: |
92 | found_subs = found_subs + 1 |
92 | found_subs = found_subs + 1 |
93 | output = output + "<p>{0}:{1}</p>".format(x[0], x[1]) |
93 | output = output + "<p>{0}:{1}</p>".format(subscriber[0], subscriber[1]) |
94 | 94 | ||
95 | if found_subs == 0: |
95 | if found_subs == 0: |
96 | output = output + '<p>None</p>' |
96 | output = output + '<p>None</p>' |
97 | 97 | ||
98 | output = output + '</body>' |
98 | output = output + '</body>' |
Line 136... | Line 136... | ||
136 | client_expires = int(time.time()) + int(client_ttl) |
136 | client_expires = int(time.time()) + int(client_ttl) |
137 | 137 | ||
138 | print "Client subscribed: {0}:{1}, searching for targets {2}".format(client_ip, client_port, client_targets) |
138 | print "Client subscribed: {0}:{1}, searching for targets {2}".format(client_ip, client_port, client_targets) |
139 | 139 | ||
140 | # Remove all expired entries, and previous entries of that client |
140 | # Remove all expired entries, and previous entries of that client |
141 | for x in g_subscribed[:]: |
141 | for subscriber in g_subscribed[:]: |
142 | if int(time.time()) > x[2]: |
142 | if int(time.time()) > subscriber[2]: |
143 | g_subscribed.remove(x) |
143 | g_subscribed.remove(subscriber) |
144 | elif (x[0] == client_ip) and (x[1] == client_port) and (x[3] == client_targets): |
144 | elif (subscriber[0] == client_ip) and (subscriber[1] == client_port) and (subscriber[3] == client_targets): |
145 | g_subscribed.remove(x) |
145 | g_subscribed.remove(subscriber) |
146 | 146 | ||
147 | # Now add our new client |
147 | # Now add our new client |
148 | g_subscribed.append([client_ip, client_port, client_expires, client_targets]) |
148 | g_subscribed.append([client_ip, client_port, client_expires, client_targets]) |
149 | 149 | ||
150 | # Send parameters of the device(s) |
150 | # Send parameters of the device(s) |
Line 157... | Line 157... | ||
157 | if pvget(postvars, "action")[0] == "server_alert": # 1.3.6.1.4.1.37476.2.4.1.2 |
157 | if pvget(postvars, "action")[0] == "server_alert": # 1.3.6.1.4.1.37476.2.4.1.2 |
158 | server_targets = pvget(postvars, "targets") |
158 | server_targets = pvget(postvars, "targets") |
159 | 159 | ||
160 | found_g = 0 |
160 | found_g = 0 |
161 | 161 | ||
162 | for subscriber in g_subscribed: |
162 | for subscriber in g_subscribed[:]: |
163 | client_ip = subscriber[0] |
163 | client_ip = subscriber[0] |
164 | client_port = subscriber[1] |
164 | client_port = subscriber[1] |
165 | client_expires = subscriber[2] |
165 | client_expires = subscriber[2] |
166 | client_targets = subscriber[3] |
166 | client_targets = subscriber[3] |
- | 167 | ||
- | 168 | if int(time.time()) > client_expires: |
|
- | 169 | g_subscribed.remove(subscriber) |
|
- | 170 | else: |
|
167 | found_c = 0 |
171 | found_c = 0 |
168 | for st in server_targets: |
172 | for st in server_targets: |
169 | for ct in client_targets: |
173 | for ct in client_targets: |
170 | if ct == st: |
174 | if ct == st: |
171 | found_c = found_c + 1 |
175 | found_c = found_c + 1 |