-
Notifications
You must be signed in to change notification settings - Fork 1
Client (API)
- buffer_size |
int
| Whatever was passed intobuffer_size
(see below) - ip |
str
| Whatever was passed intoip
(see below) - port |
int
| Whatever was passed intoport
(see below) - running |
bool
| Set to False when created, Set to True when you callrun
, and when False, it stops therun
method - tasks |
queue.Queue
| Not used anymore - sock |
socket.socket
| The socket used to communicate with the server - ssl |
bool
| If True, the socket uses a form of ssl - timeout |
int
| Amount of seconds the client should wait for a server's response
__init__(self, ip: str, port: int, buffer_size: int=2047, family: int=socket.AF_INET, type: int=socket.SOCK_STREAM, use_ssl: bool=True, ssl_data: dict=None, timeout: int=2)
- ip |
str
| IP is the addr of the target computer, in which QServer is running on. - port |
int
| The port, that the target QServer is running on. - buffer_size |
int
| How many bytes of data it can read and send at a time. - family & type |
int
| The type of socket used for communication see the socket lib for details. - use_ssl |
bool
| If True, the socket will be wrapped to use ssl, usingssl_data
- ssl_data |
dict
| The kwargs to be passed into wrap_socket - timeout |
int
| The amount of time the client will wait for the server's response.
This is the same as quicknet.server.QServer.error_handler
This function sends a event to the server, and passes in the supplied data (in args and kwargs) to that function on the server. This function can't send more data, then the amount of data it can receive.
- handler |
str
| The name of the event_handler to be called on the server - args & kwargs |
tuple
&dict
| Data to be sent to the event handler
This starts a loop, constantly checking for information from the server. When it receives some, it
will trigger the event_handler, if one exists. If you want to run this as a thread, do .start()
instead of .run()
Closes the socket, and peacefully ends the run loop. If it was run as a thread, the thread will stop.
This function allows you to access the server's shared variables. You can do so like
client = QClient("127.0.0.1", 5431) # Doesn't have to be this port, just the server's port
print("Joined as " + client['name'])
This is assuming the server has set a variable. If it hasn't, it returns None
. Otherwise, if
the server isn't responding, and the timeout is passed, a TimeoutError
is raised. Else wise
it returns the value, set by the server.
This function allows you to set the server's shared variables. You can do so like
client = QClient("127.0.0.1", 531) # Doesn't have to be this port, just the server's port
client["DIRECTION"] = "UP"
This function won't wait for a response. However, if a response is given, it will log it
at level DEBUG
. This will do nothing, if the server has locked the sharing of variables.
This function allows you to delete the server's shared variables. You can do so like
client = QClient("127.0.0.1", 531) # Doesn't have to be this port, just the server's port
del client["JOIN-TIME"]
This function won't wait for a response. However, if a response is given, it will log it
at level DEBUG
. This will do nothing, if the server has locked the sharing of variables.
Thank you for using quick-connect, made by Nathan Zilora