A small Server and Client creator
Project description
This is a little library for creating Servers and Clients to send data.
Usage:
ClientStream:
myclient = Clientstream(addr, port) #Generate
myclient.connect() #Connect
myclient.setListener("connect", connect) #Replace the second argument with a function. Overgiving args:
myclient.setListener("disconnect", disconnect) #Replace the second argument with a function. Overgiving args:
myclient.setListener("recv", recv) #Replace the second argument with a function. Overgiving args: None, data
myclient.setListener("recvexception", recv) #Replace the second argument with a function. Overgiving args: exception
myclient.send("something", delay) #Send; delay is by default 300 ms
myclient.pause() #Pause
myclient.unpause() #Unpause
is_paused = myclient.getpaused() #Getpaused
myclient.stop() #Stop
ServerStream:
myserver = Serverstream(addr, port, maxclients) #Generate
myserver.connect() #Connect
myserver.setListener("connect", connect) #Replace the second argument with a function. Overgiving args: sock_id
myserver.setListener("disconnect", disconnect) #Replace the second argument with a function. Overgiving args: sock_id
myserver.setListener("recv", recv) #Replace the second argument with a function. Overgiving args: sock, data
myserver.setListener("recvexception", recv) #Replace the second argument with a function. Overgiving args: exception
myserver.send(sock_id "something", delay) #Send to sock_id; delay is by default 300 ms
myserver.pause() #Pause
myserver.unpause() #Unpause
is_paused = myserver.getpaused() #Getpaused
myserver.stop() #Stop
Packet: There are 3 default types of Packets. The JSON, pickle and repr Packet. In this case, we use a JSONPacket to show it: mypacket = JSONPACKET(data) #Create; data is by default {} mypacket.set_data({"1":1, "2":2}) #Set print(mypacket.get_data()) #Getall print(mypacket.get_data("1")) #Get myclient.send(mypacket.pack()) #Send mypacket = JSONPacket.unpack(raw_data)
to create an own Packet, you must create this: class MyPacket(easystreaming.Packet): def pack(self): #return bytes of self.data def unpack(rdata): #return Packet with unpacked data
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for easystreaming-0.0.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35c0f452c9587773bc351d8e8e7bdea58bf0fe7f3c68970c6bf871d29265018a |
|
MD5 | d1177b23adba48ac99fc56be742ab21c |
|
BLAKE2b-256 | 3afe52b21396087e6b4f8b9c965eefbd00e93f09aa03f2f52c547e29af1b45e6 |