royalnet.network¶
-
class
royalnet.network.
Message
¶ A message sent through the Royalnet.
-
class
royalnet.network.
ServerErrorMessage
(reason)¶ Something went wrong in the connection to the
royalnet.network.RoyalnetServer
.
-
class
royalnet.network.
InvalidSecretEM
(reason)¶ The sent secret was incorrect.
This message terminates connection to the
royalnet.network.RoyalnetServer
.
-
class
royalnet.network.
InvalidDestinationEM
(reason)¶ The
royalnet.network.Package
destination was invalid or not found.
-
class
royalnet.network.
InvalidPackageEM
(reason)¶ The sent
royalnet.network.Package
was invalid.
-
class
royalnet.network.
RoyalnetLink
(master_uri: str, secret: str, link_type: str, request_handler, *, loop: asyncio.events.AbstractEventLoop = <_WindowsSelectorEventLoop running=False closed=False debug=False>)¶ -
connect
()¶
-
identify
() → None¶
-
receive
() → royalnet.network.packages.Package¶
-
request
(message, destination)¶
-
run
()¶
-
send
(package: royalnet.network.packages.Package)¶
-
-
exception
royalnet.network.
NetworkError
(error_msg: royalnet.network.messages.ServerErrorMessage, *args)¶
-
exception
royalnet.network.
NotConnectedError
¶ The
royalnet.network.RoyalnetLink
is not connected to aroyalnet.network.RoyalnetServer
.
-
exception
royalnet.network.
NotIdentifiedError
¶ The
royalnet.network.RoyalnetLink
has not identified yet to aroyalnet.network.RoyalnetServer
.
-
class
royalnet.network.
Package
(data, destination: str, source: str, *, source_conv_id: str = None, destination_conv_id: str = None)¶ A Royalnet package, the data type with which a
royalnet.network.RoyalnetLink
communicates with aroyalnet.network.RoyalnetServer
or another link.-
__init__
(data, destination: str, source: str, *, source_conv_id: str = None, destination_conv_id: str = None)¶ Create a Package.
- Parameters
data – The data that should be sent. Usually a
royalnet.network.Message
.destination – The
link_type
of the destination node, or alternatively, thenid
of the node. Can also be theNULL
value to send the message to nobody.source – The
nid
of the node that created this Package.source_conv_id – The conversation id of the node that created this package. Akin to the sequence number on IP packets.
destination_conv_id – The conversation id of the node that this Package is a reply to.
-
reply
(data) → royalnet.network.packages.Package¶ Reply to this Package with another Package.
- Parameters
data – The data that should be sent. Usually a
royalnet.network.Message
.- Returns
The reply Package.
-
-
class
royalnet.network.
RoyalnetServer
(address: str, port: int, required_secret: str, *, loop: asyncio.events.AbstractEventLoop = <_WindowsSelectorEventLoop running=False closed=False debug=False>)¶ -
find_client
(*, nid: str = None, link_type: str = None) → List[royalnet.network.royalnetserver.ConnectedClient]¶
-
find_destination
(package: royalnet.network.packages.Package) → List[royalnet.network.royalnetserver.ConnectedClient]¶ Find a list of destinations for the package.
- Parameters
package – The package to find the destination of.
- Returns
A
list
ofConnectedClients
to send the package to.
-
listener
(websocket: websockets.server.WebSocketServerProtocol, request_uri: str)¶
-
route_package
(package: royalnet.network.packages.Package) → None¶ Executed every time a package is received and must be routed somewhere.
-
serve
()¶
-
start
()¶
-
-
class
royalnet.network.
RequestSuccessful
¶ The sent request was successful.
-
raise_on_error
() → None¶ If the reply is an error, raise an error, otherwise, do nothing.
Does nothing.
-
-
class
royalnet.network.
RequestError
(exc: Exception)¶ The sent request wasn’t successful.
-
__init__
(exc: Exception)¶ Create a RequestError.
- Parameters
exc – The exception that caused the error in the request.
-
raise_on_error
() → None¶ If the reply is an error, raise an error, otherwise, do nothing.
:raises Always raises a
royalnet.error.RoyalnetError
, containing the exception that caused the error.:
-
-
class
royalnet.network.
RoyalnetConfig
(master_uri: str, master_secret: str)¶