mirror of
https://github.com/markqvist/Sideband.git
synced 2025-07-22 06:29:14 -04:00
Added basic plugin examples
This commit is contained in:
parent
ced7e881b9
commit
84bc1f786d
3 changed files with 72 additions and 0 deletions
34
docs/example_plugins/service.py
Normal file
34
docs/example_plugins/service.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
import RNS
|
||||
import time
|
||||
import threading
|
||||
|
||||
class BasicServicePlugin(SidebandServicePlugin):
|
||||
service_name = "service_example"
|
||||
|
||||
def service_jobs(self):
|
||||
while self.should_run:
|
||||
time.sleep(5)
|
||||
RNS.log("Service ping from "+str(self))
|
||||
|
||||
RNS.log("Jobs stopped running for "+str(self))
|
||||
|
||||
def start(self):
|
||||
# Do any initialisation work here
|
||||
RNS.log("Basic service plugin example starting...")
|
||||
self.should_run = True
|
||||
self.service_thread = threading.Thread(target=self.service_jobs, daemon=True)
|
||||
self.service_thread.start()
|
||||
|
||||
# And finally call start on superclass
|
||||
super().start()
|
||||
|
||||
def stop(self):
|
||||
# Do any teardown work here
|
||||
self.should_run = False
|
||||
|
||||
# And finally call stop on superclass
|
||||
super().stop()
|
||||
|
||||
# Finally, tell Sideband what class in this
|
||||
# file is the actual plugin class.
|
||||
plugin_class = BasicServicePlugin
|
Loading…
Add table
Add a link
Reference in a new issue