frost.client package¶
Subpackages¶
Submodules¶
frost.client.auth module¶
-
frost.client.auth.get_auth(func: Callable) → Callable¶ A decorator to get the saved auth token and id.
- Parameters
func (Callable) – The function that is being wrapped
- Returns
The inner execute function
- Return type
Callable
-
frost.client.auth.get_auth_token¶ Returns the saved auth token.
- Returns
The auth token saved in
.frost- Return type
Optional[str]
-
frost.client.auth.get_id¶ Returns the saved id.
- Returns
The ID saved in
.frost- Return type
Optional[str]
frost.client.client module¶
-
class
frost.client.client.FrostClient(ip: str = '127.0.0.1', port: int = 5555)¶ Bases:
frost.client.socketio.base_client.BaseClientThe Frost Client.
- Parameters
ip (str, optional) – The IP address of the server to connect to, defaults to ‘127.0.0.1’
port (int, optional) – The port of the server to connect to, defaults to 5555
-
connect() → None¶ Connect to the server and begin listening for events.
-
create_room(room_name: str, token: str, id_: str) → None¶ Create a new room in a server.
- Parameters
room_name (str) – The name of the room to create
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
get_invite_code(room_id: int, token: str, id_: str) → None¶ Get the invite code of a room in a server.
- Parameters
room_id (int) – The ID of the room to get an invite code from
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
get_joined_rooms(token: str, id_: str) → None¶ Get all the joined rooms of the currently logged in user.
- Parameters
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
get_room_members(room_id: int, token: str, id_: str) → None¶ Get all the members of a specific room.
- Parameters
room_id (int) – The ID of the room to get the members of
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
get_room_msgs(room_id: int, token: str, id_: str) → None¶ Get all messages from a specific room in a server.
- Parameters
room_id (int) – The ID of the room to get the messages from
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
join_room(invite_code: str, token: str, id_: str) → None¶ Join a room in a server with an invite code.
- Parameters
invite_code (str) – The invite code the room to join
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
leave_room(room_id: int, token: str, id_: str) → None¶ Leave a joined room in a server.
- Parameters
room_id (int) – The ID of the room to leave
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
login(username: str, password: str) → None¶ Login to the server.
- Parameters
username (str) – The username of the account
password (str) – The password of the account
-
register(username: str, password: str) → None¶ Register an account on the server.
- Parameters
username (str) – The desired username of the account
password (str) – The desired password of the account
-
send_msg(room_id: int, msg: str, token: str, id_: str) → None¶ Send a message to other users on a server in a specific room.
- Parameters
room_id (int) – The ID of the room to send the message to
msg (str) – The desired message to send
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
frost.client.headers module¶
frost.client.objects module¶
-
class
frost.client.objects.Memory¶ Bases:
objectStores information that needs to be passed around and easily accessible.
-
classmethod
add_room_members(room_id: int, *members: Tuple[Dict[str, Union[str, int]]]) → None¶ Store members within a room stored in
Memory.rooms.- Parameters
room_id (int) – The ID of the room to store the members in
-
classmethod
add_rooms(*rooms: Tuple[Dict[str, Union[str, int]]]) → None¶ Store rooms as
frost.client.objects.Roomobjects inMemory.rooms.- Parameters
*rooms –
The rooms to store
-
classmethod
get_room_member_changes() → Dict[str, Dict[int, frost.client.objects.Room]]¶ Get changes in whether a members left or joined rooms.
- Returns
Room member changes
- Return type
Dict[str, Dict[int, ‘Room’]]
-
member_changes= {'joined': {}, 'left': {}}¶ New members which have just joined a room or members who have just left the room, grouped by room.
-
classmethod
remove_room_member(room_id: int, user_id: int) → None¶ Remove a room member who left stored in a room.
- Parameters
room_id (int) – The room’s ID the user left from
user_id (int) – The ID of the user who left
-
rooms= {}¶ The rooms in a server.
-
classmethod
set_invite_code(room_id: int, invite_code: str) → None¶ Store the invite code of a specific room.
- Parameters
room_id (int) – The ID of the room that the invite code corresponds to
invite_code (str) – The invite code to store
-
classmethod
-
class
frost.client.objects.Room(id_: int, name: str, members: Dict[int, User] = {})¶ Bases:
objectRepresents a room in a server, storing information about one.
- Parameters
id (int) – The room’s ID
name (str) – The room’s name
members (Dict[int, 'User'], optional) – The members a part of the room, defaults to list()
-
class
frost.client.objects.User(id_: int, username: str)¶ Bases:
objectRepresents a user in a server, storing information about one.
- Parameters
id (int) – The user’s ID
username (str) – The user’s username
Module contents¶
-
class
frost.client.FrostClient(ip: str = '127.0.0.1', port: int = 5555)¶ Bases:
frost.client.socketio.base_client.BaseClientThe Frost Client.
- Parameters
ip (str, optional) – The IP address of the server to connect to, defaults to ‘127.0.0.1’
port (int, optional) – The port of the server to connect to, defaults to 5555
-
connect() → None¶ Connect to the server and begin listening for events.
-
create_room(room_name: str, token: str, id_: str) → None¶ Create a new room in a server.
- Parameters
room_name (str) – The name of the room to create
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
get_invite_code(room_id: int, token: str, id_: str) → None¶ Get the invite code of a room in a server.
- Parameters
room_id (int) – The ID of the room to get an invite code from
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
get_joined_rooms(token: str, id_: str) → None¶ Get all the joined rooms of the currently logged in user.
- Parameters
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
get_room_members(room_id: int, token: str, id_: str) → None¶ Get all the members of a specific room.
- Parameters
room_id (int) – The ID of the room to get the members of
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
get_room_msgs(room_id: int, token: str, id_: str) → None¶ Get all messages from a specific room in a server.
- Parameters
room_id (int) – The ID of the room to get the messages from
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
join_room(invite_code: str, token: str, id_: str) → None¶ Join a room in a server with an invite code.
- Parameters
invite_code (str) – The invite code the room to join
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
leave_room(room_id: int, token: str, id_: str) → None¶ Leave a joined room in a server.
- Parameters
room_id (int) – The ID of the room to leave
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
login(username: str, password: str) → None¶ Login to the server.
- Parameters
username (str) – The username of the account
password (str) – The password of the account
-
register(username: str, password: str) → None¶ Register an account on the server.
- Parameters
username (str) – The desired username of the account
password (str) – The desired password of the account
-
send_msg(room_id: int, msg: str, token: str, id_: str) → None¶ Send a message to other users on a server in a specific room.
- Parameters
room_id (int) – The ID of the room to send the message to
msg (str) – The desired message to send
token (str) – The user’s token, auto filled by
frost.client.auth.get_auth()id (str) – The user’s ID, auto filled by
frost.client.auth.get_auth()
-
class
frost.client.Status¶ Bases:
enum.EnumThe status enums
-
DUPLICATE_ROOM_NAME: int = 6¶
-
DUPLICATE_USERNAME: int = 3¶
-
EMPTY_ROOM_NAME: int = 5¶
-
INVALID_AUTH: int = 1¶
-
INVALID_INVITE: int = 7¶
-
PERMISSION_DENIED: int = 2¶
-
ROOM_NOT_FOUND: int = 4¶
-
SUCCESS: int = 0¶
-
-
class
frost.client.threaded(*args: Any, **kwargs: Any)¶ Bases:
objectA decorator to thread a function/method.
-
frost.client.get_auth(func: Callable) → Callable¶ A decorator to get the saved auth token and id.
- Parameters
func (Callable) – The function that is being wrapped
- Returns
The inner execute function
- Return type
Callable
-
class
frost.client.Memory¶ Bases:
objectStores information that needs to be passed around and easily accessible.
-
classmethod
add_room_members(room_id: int, *members: Tuple[Dict[str, Union[str, int]]]) → None¶ Store members within a room stored in
Memory.rooms.- Parameters
room_id (int) – The ID of the room to store the members in
-
classmethod
add_rooms(*rooms: Tuple[Dict[str, Union[str, int]]]) → None¶ Store rooms as
frost.client.objects.Roomobjects inMemory.rooms.- Parameters
*rooms –
The rooms to store
-
classmethod
get_room_member_changes() → Dict[str, Dict[int, frost.client.objects.Room]]¶ Get changes in whether a members left or joined rooms.
- Returns
Room member changes
- Return type
Dict[str, Dict[int, ‘Room’]]
-
member_changes= {'joined': {}, 'left': {}}¶ New members which have just joined a room or members who have just left the room, grouped by room.
-
classmethod
remove_room_member(room_id: int, user_id: int) → None¶ Remove a room member who left stored in a room.
- Parameters
room_id (int) – The room’s ID the user left from
user_id (int) – The ID of the user who left
-
rooms= {}¶ The rooms in a server.
-
classmethod
set_invite_code(room_id: int, invite_code: str) → None¶ Store the invite code of a specific room.
- Parameters
room_id (int) – The ID of the room that the invite code corresponds to
invite_code (str) – The invite code to store
-
classmethod