-
Notifications
You must be signed in to change notification settings - Fork 1
Server (API)
- local |
bool
| Whatever was passed intolocal_only
(see below) - port |
int
| Whatever was passed intoport
(see below) - running |
bool
| Starts as True, even before running therun
method. When False, it breaks the loop. - buffer_size |
int
| Whatever was passed intobuffer_size
(see below) - clients |
dict
| The keys are the IDs of the clients, and the values arequicknet.worker.ClientWorker
objects. - queues |
dict
| Not used anymore
__init__(self, port: int, local_only: bool=False, buffer_size: int=2047, family: int=socket.AF_INET, type: int=socket.SOCK_STREAM)
-
port | arg
Type:
int
This tells the server, what port you want the server to run on.
-
local_only | kwarg (False)
Type:
bool
If this kwarg is True, it will bind the port to your localhost. Otherwise, it will bind to 0.0.0.0
-
buffer_size | kwarg (2047)
Type:
int
This defines how many bytes of data it will read, and, how much it will send. If you supply too much data, it will raise
quicknet.utils.DataOverflowError
-
family & type | kwarg (socket.AF_INET & socket.SOCK_STREAM)
Type:
int
These are settings for how the socket connection will work. It's good to play around with these, depending on what your doing. See the socket docs for more info.
Args & Kwargs
-
callback | kwarg (None)
Type:
callable
This function sets a handler, for all errors that might occur in the project. This keeps it running, even if
something goes wrong. WARNING, This function is called when a server object is created, so if you intend on
saving the default handler, sys.excepthook
, do that before creating the server. If the callback is None, it
replaces sys.excepthook
with traceback.print_exception
. Feel free to change the callback, without this
function, if necessary.
This method simply stops the server from running nicely, and closes all client connections. If the server isn't
running yet, it will raise quicknet.utils.NotRunningError
This method binds the server to the computer, and accepts all connections on that port. When a NEW client
joins, it emits "CONNECTION" with the conn socket object, and the address of the client. It the spawns a worker
for that client, and starts listening for connections. If you want this to run synchronously, call run
, if
you want it to be a thread, call start
instead. It then adds to the worker to the server's clients
property.
Does the same thing as run
, but does it as a thread.
-
handler | arg
Type:
str
This is the name of the listener, that will be triggered for each client.
-
args and kwargs | both
Type:
anything
This is the data that will be passed into the listeners
This does the same thing, that quicknet.worker.emit
does, however iterates through each client, and emits
the data that was passed in.
Thank you for using quick-connect, made by Nathan Zilora