Ejemplo n.º 1
0
#
packet = Packet(315)
#Now we can add data to the packet. Data in a packet is represented by the PacketData class,
#which passes 2 arguments. The first is the DID(Data ID), and the second is the actual data.
#We'll add one of each supported data type.
'''
Data Type Protocol:
1. String
2. Integer
3. Float
4. Boolean
5. (TODO) File
6. Other (Program uses JSON to convert value to string and back)
'''
#We'll add a string with DID 1
packet.addData(PacketData(1,"Testing 123"))
#We'll add an integer with DID 2
packet.addData(PacketData(2,123))
#We'll add a float with DID 3
packet.addData(PacketData(3,1.23))
#We'll add a boolean with DID 4
packet.addData(PacketData(4,True))
#We'll add a list(other) of different types of data with DID 5
packet.addData(PacketData(5,['321 Testing',123,1.23,True]))

#Two methods that allow us to discern data printed from server vs client
#Normally the server program would be seperate from that of the client though

def clientMsg(msg):
    print "[CLIENT] " + msg