summaryrefslogtreecommitdiff
path: root/server/client.py
diff options
context:
space:
mode:
authorgoblin911 <[email protected]>2013-08-25 21:16:45 +0800
committergoblin911 <[email protected]>2013-08-25 21:16:45 +0800
commit2efdc2f20f0306791ced5ec78a1acddfaf086f42 (patch)
treea85f2b32d6e6da9d7329ab975fea3bd79e1b94b6 /server/client.py
parente5599da7fdd344fdcb49e8d6780a1e2ad358ee2d (diff)
parent263967cbb477983ae8680b431c1d93f102971c30 (diff)
Merge branch 'master' of https://github.com/Determinant/piztor
Conflicts: client/Piztor/bin/classes/com/macaroon/piztor/ActMgr.class client/Piztor/bin/classes/com/macaroon/piztor/AppMgr.class client/Piztor/bin/classes/com/macaroon/piztor/R$drawable.class client/Piztor/bin/classes/com/macaroon/piztor/R$id.class client/Piztor/bin/classes/com/macaroon/piztor/R$layout.class client/Piztor/bin/classes/com/macaroon/piztor/R$menu.class client/Piztor/bin/classes/com/macaroon/piztor/R$string.class client/Piztor/gen/com/macaroon/piztor/R.java client/Piztor/res/values/strings.xml client/bin/classes/com/macaroon/piztor/ActStatus.class client/bin/classes/com/macaroon/piztor/EmptyStatus.class client/bin/classes/com/macaroon/piztor/Setting.class client/src/com/macaroon/piztor/AppMgr.java client/src/com/macaroon/piztor/Setting.java
Diffstat (limited to 'server/client.py')
-rw-r--r--server/client.py58
1 files changed, 0 insertions, 58 deletions
diff --git a/server/client.py b/server/client.py
deleted file mode 100644
index 15f4bbc..0000000
--- a/server/client.py
+++ /dev/null
@@ -1,58 +0,0 @@
-import socket
-import sys
-from struct import *
-from random import random
-from time import sleep
-
-def get_hex(data):
- return "".join([hex(ord(c))[2:].zfill(2) for c in data])
-
-HOST, PORT = "localhost", 9990
-
-def gen_auth(username, password):
- data = pack("!B", 0)
- data += username
- data += "\0"
- data += password
- return data
-
-def gen_update_location(token, lat, lont):
- return pack("!BLdd", 2, token, lat, lont)
-
-def gen_request_location(token, gid):
- return pack("!BLL", 3, token, gid)
-
-def send(data):
- try:
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.connect((HOST, PORT))
-# print "Client " + str(sys.argv[1]) + ": connected"
- sock.sendall(data)
- print get_hex(data)
-# print "Client " + str(sys.argv[1]) + ": sent"
-# sock.shutdown(socket.SHUT_WR)
-# print "Client " + str(sys.argv[1]) + ": shutdown"
- received = sock.recv(1024)
- finally:
- print "adf"
- sock.close()
-
- print "Sent {}".format(get_hex(data))
- print "Received: {}".format(get_hex(data))
- return received
-
-#print "Client spawned:" + str(sys.argv[1])
-rec = send(gen_auth("hello", "world"))
-opt, token, status = unpack("!BLB", rec)
-
-rec = send(gen_update_location(token, random(), random()))
-opc, status = unpack("!BB", rec)
-
-rec = send(gen_request_location(token, 1))
-opc, length = unpack("!BL", rec[:5])
-idx = 5
-for i in xrange(length):
- uid, lat, lng = unpack("!Ldd", rec[idx:idx + 20])
- print (uid, lat, lng)
- idx += 20
-# sleep(60)