client ¶
Protocol factory -- client.
ClientFactory ¶
ClientFactory(motd: bytes, blacklist: List[str], metar_manager: MetarManager, plugin_manager: PluginManager, db_engine: AsyncEngine)
Factory of ClientProtocol.
Attributes:
-
clients
(Dict[bytes, Client]
) –All clients, Dict[callsign(bytes), Client]
-
heartbeat_task
(Task[NoReturn] | None
) –Task to send heartbeat to clients.
-
motd
(List[bytes]
) –The Message Of The Day.
-
blacklist
(List[str]
) –IP blacklist.
-
metar_manager
(MetarManager
) –The metar manager.
-
plugin_manager
(PluginManager
) –The plugin manager.
-
db_engine
(AsyncEngine
) –Async sqlalchemy engine.
-
password_hasher
(PasswordHasher
) –Argon2 password hasher.
Source code in src/pyfsd/factory/client.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
__call__ ¶
__call__() -> ClientProtocol
Create a ClientProtocol instance.
Source code in src/pyfsd/factory/client.py
115 116 117 |
|
broadcast ¶
broadcast(*lines: bytes, check_func: BroadcastChecker = lambda , : True, auto_newline: bool = True, from_client: Optional[Client] = None) -> bool
Broadcast a message.
Parameters:
-
lines
(bytes
, default:()
) –Lines to be broadcasted.
-
check_func
(BroadcastChecker
, default:lambda , : True
) –Function to check if message should be sent to a client.
-
auto_newline
(bool
, default:True
) –Auto put newline marker between lines or not.
-
from_client
(Optional[Client]
, default:None
) –Where the message from.
Return
Lines sent to at least client or not.
Source code in src/pyfsd/factory/client.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
check_auth async
¶
Check if password and username is correct.
Source code in src/pyfsd/factory/client.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
get_heartbeat_task ¶
Get heartbeat task.
Source code in src/pyfsd/factory/client.py
90 91 92 93 94 95 96 97 98 99 100 101 |
|
heartbeat ¶
heartbeat() -> None
Send heartbeat to clients.
Source code in src/pyfsd/factory/client.py
103 104 105 106 107 108 109 110 111 112 113 |
|
remove_all_clients ¶
remove_all_clients() -> None
Remove all clients.
Source code in src/pyfsd/factory/client.py
220 221 222 223 |
|
send_to ¶
Send lines to a specified client.
Parameters:
-
callsign
(bytes
) –The client's callsign.
-
lines
(bytes
, default:()
) –Lines to be broadcasted.
-
auto_newline
(bool
, default:True
) –Auto put newline marker between lines or not.
Returns:
-
bool
–Is there a client called {callsign} (and is message sent or not).
Source code in src/pyfsd/factory/client.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|