aboutsummaryrefslogtreecommitdiff
path: root/packet.py
diff options
context:
space:
mode:
authorGrissess <grissess@nexusg.org>2015-06-14 04:30:59 -0400
committerGrissess <grissess@nexusg.org>2015-06-14 04:30:59 -0400
commitb3606eb073651b92a7f3ba7df56d6a7d697bcc13 (patch)
treeec18209d58b63f18cbaaa7aaaed093ec2fe3627e /packet.py
parent0e2f4d381644e062b840ec27cecd18e43b0c94be (diff)
Added a major packet type and cleaned up
Diffstat (limited to 'packet.py')
-rw-r--r--packet.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/packet.py b/packet.py
index 951425c..aefa758 100644
--- a/packet.py
+++ b/packet.py
@@ -6,7 +6,7 @@ class Packet(object):
def __init__(self, cmd, *data):
self.cmd = cmd
self.data = data
- if len(data) >= 8:
+ if len(data) > 8:
raise ValueError('Too many data')
self.data = list(self.data) + [0] * (8-len(self.data))
@classmethod
@@ -20,4 +20,11 @@ class CMD:
KA = 0 # No important data
PING = 1 # Data are echoed exactly
QUIT = 2 # No important data
- PLAY = 3 # seconds, microseconds, frequency (Hz), amplitude (0-255)
+ PLAY = 3 # seconds, microseconds, frequency (Hz), amplitude (0-255), port
+ CAPS = 4 # ports, client type (1), user ident (2-7)
+
+def itos(i):
+ return struct.pack('>L', i)
+
+def stoi(s):
+ return struct.unpack('>L', s)[0]