author | ymh <ymh.work@gmail.com> |
Sun, 19 Oct 2014 12:52:38 +0200 | |
changeset 42 | 926f0426ce78 |
parent 31 | 2323ee3ad20f |
child 163 | 890d387040cf |
permissions | -rw-r--r-- |
0 | 1 |
|
2 |
# |
|
3 |
# See LICENCE for detail |
|
4 |
# Copyright (c) 2014 IRI |
|
5 |
# |
|
6 |
||
7 |
import datetime |
|
8 |
import json |
|
9 |
import uuid |
|
10 |
||
11 |
from txosc import dispatch |
|
12 |
from txosc.osc import getAddressParts |
|
13 |
from txosc.async import DatagramServerProtocol |
|
14 |
||
15 |
import ntplib |
|
16 |
||
31 | 17 |
from dateutil.tz import tzutc |
18 |
||
0 | 19 |
from baseserver import BaseProtocol |
20 |
import utils |
|
21 |
||
22 |
||
23 |
class OSCServerProtocol(DatagramServerProtocol, BaseProtocol): |
|
24 |
""" |
|
25 |
Receive UDP OSC messages |
|
26 |
""" |
|
27 |
||
28 |
def __init__(self, ws_factory, conn): |
|
29 |
self.receiver = dispatch.Receiver() |
|
30 |
self.receiver.addCallback("/pianoroll/*/", self.processPianorollAnnotation) |
|
31 |
self._init_props(ws_factory, conn) |
|
32 |
||
33 |
def processPianorollAnnotation(self, message, address): |
|
34 |
||
35 |
values = message.getValues() |
|
31 | 36 |
ts = datetime.datetime.fromtimestamp(ntplib.ntp_to_system_time(values[0]), tzutc()) |
0 | 37 |
|
38 |
params = { |
|
39 |
'ts' : ts, |
|
42
926f0426ce78
add event + event session + admin + category json management. Must rebuild database
ymh <ymh.work@gmail.com>
parents:
31
diff
changeset
|
40 |
'event_code': getAddressParts(message.address)[1], |
0 | 41 |
'channel' : utils.PIANOROLL_CHANNEL, |
42 |
'content' : values |
|
43 |
} |
|
44 |
||
45 |
self.process_annotation(params) |