-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
59 lines (46 loc) · 1.27 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#
# eyeSwitch server in Python
# Binds REP socket to tcp://*:5555
#
import zmq
import os, time
from pymouse import PyMouse
from pygame import mixer
m = PyMouse( )
mixer.init( )
acceptationSound = mixer.Sound( "acceptationSound.wav" )
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5559")
error_flag = True
counter = 0
while True:
# Wait for next request from client
message = socket.recv()
# reaction on client request
# print("Received: %s" % message)
if message == "Error":
error_flag = True
socket.send("Record")
elif message == "ask":
print "ODEBRANO PYTANIE: " + message
if error_flag==True:
if counter < 50:
print "Odsylam"
socket.send("record")
print "Odeslano"
counter +=1
else:
error_flag = False
counter = 0
socket.send("stop")
else:
socket.send("ok")
elif message == "press":
print 'else -- ' + message
else:
acceptationSound.play( )
socket.send("ok")
# m.move(1320, 740)
m.click(m.position()[0], m.position()[1], 1)
#sending response to client