parent
a5bae2c0e2
commit
87008043db
|
@ -24,7 +24,9 @@ function setup() {
|
||||||
window.m = e
|
window.m = e
|
||||||
let type, pos, x, y, data, img, code, msg
|
let type, pos, x, y, data, img, code, msg
|
||||||
type = e.data.split('%')[0]
|
type = e.data.split('%')[0]
|
||||||
if ( type == 'pic' ) {
|
if (type == 'ver') {
|
||||||
|
ws.send('pass ' + localStorage.getItem('password'))
|
||||||
|
} else if ( type == 'pic' ) {
|
||||||
pos = e.data.split('%')[1]
|
pos = e.data.split('%')[1]
|
||||||
x = Number(pos.split('x')[0])
|
x = Number(pos.split('x')[0])
|
||||||
y = Number(pos.split('x')[1])
|
y = Number(pos.split('x')[1])
|
||||||
|
@ -63,7 +65,7 @@ function setup() {
|
||||||
canvas.style.display = 'none'
|
canvas.style.display = 'none'
|
||||||
}
|
}
|
||||||
ws.onopen = function(e) {
|
ws.onopen = function(e) {
|
||||||
ws.send('pass ' + localStorage.getItem('password'))
|
ws.send('maxver 1')
|
||||||
}
|
}
|
||||||
setInterval(function(){ws.send('ack')}, 3000)
|
setInterval(function(){ws.send('ack')}, 3000)
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ class Client:
|
||||||
class HCRAServer(tornado.websocket.WebSocketHandler):
|
class HCRAServer(tornado.websocket.WebSocketHandler):
|
||||||
def open(self):
|
def open(self):
|
||||||
self.has_auth = False
|
self.has_auth = False
|
||||||
|
self.version = None
|
||||||
|
|
||||||
def on_close(self):
|
def on_close(self):
|
||||||
global client
|
global client
|
||||||
|
@ -85,10 +86,15 @@ class HCRAServer(tornado.websocket.WebSocketHandler):
|
||||||
|
|
||||||
def on_message(self, message):
|
def on_message(self, message):
|
||||||
action = message.split(' ', 1)[0]
|
action = message.split(' ', 1)[0]
|
||||||
if not self.has_auth:
|
if self.version is None:
|
||||||
print(message)
|
if action == 'maxver':
|
||||||
print(action)
|
self.version = min(int(message.split(' ', 1)[1]), 1)
|
||||||
print(action != 'pass')
|
self.write_message(f'ver%{self.version}')
|
||||||
|
else:
|
||||||
|
self.write_message('err%*mustmaxver%Client must send version')
|
||||||
|
self.close()
|
||||||
|
return
|
||||||
|
elif not self.has_auth:
|
||||||
if action != 'pass':
|
if action != 'pass':
|
||||||
self.write_message('err%*mustauth%Authentication required')
|
self.write_message('err%*mustauth%Authentication required')
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -125,7 +131,6 @@ class HCRAServer(tornado.websocket.WebSocketHandler):
|
||||||
if action == 'ack':
|
if action == 'ack':
|
||||||
self.client.good = True
|
self.client.good = True
|
||||||
else:
|
else:
|
||||||
print(message)
|
|
||||||
_, x, y, w, is_long = message.split(' ')
|
_, x, y, w, is_long = message.split(' ')
|
||||||
x, y, w, is_long = int(x), int(y), int(w), is_long == 'true'
|
x, y, w, is_long = int(x), int(y), int(w), is_long == 'true'
|
||||||
imgproc.touch(x, y, w, is_long)
|
imgproc.touch(x, y, w, is_long)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user