Welcome to OpenNotify, this a Push Notification Server and Client Management for Your Own and Commercial use.
Setup Server
Setup Client
First setup all requierd variables and objects
from OpenNotify import Server, MessageModel
this model for thinks what you get and store in server
Note
id{string) and to_id(string) is important for server to run
class Message(MessageModel):
id:str
to_id:str
body:str
icon:str
server = Server('127.0.0.1', 200)
server.setModel(Message)
Note
If you Starting the server for first time use this method if you already run the server skip this part
server.generateID('OpenNotify')
server.start()
First setup all requierd variables and objects
from OpenNotify import Client, MessageModel
Note
this model will be same as the server message model id{string) and to_id(string) is important for sending message
class Message(MessageModel):
id:str
to_id:str
body:str
icon:str
{!Note} It will give the MessageModel Object as the parameter
load_message(message:Message) -> None:
print(f" {message.id} -> {message.body}")
client = Client( '127.0.0.1', 200)
client.setModel(Message)
client.setAppId('6842944a-435c-41fc-b3a4-cdb918352214')
client.setAppName('OpenNotify')
client.setId('Client456')
client.receiver.connect(load_message)
Note
If the Server is not running it will raise a ConnectionRefusedError
client.start()
message = Message()
message.id = 'Cleint456'
message.to_id = 'Client123'
message.body = "Hi bro"
client.sendMessage(message)