Skip to content

killian-dtn/python-socket-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-socket-server

Python 3.7+

Usage

Basic

from kserver import KServer, KServerInterface

server = KServer(55555) # Listening on port 55555
kiface = KServerInterface(server)
kiface.Run()

Custom Log

# ...
def CustomLog(msg):
  print(f"Something just happened : {msg}")

server = KServer(55555, CustomLog)
# ...

Add command

# ...
kiface = KServerInterface(server)

def Send(interface, target, *args):
  # Mandatory args:
  # - interface is the KServerInterface object that will call the command
  # - target is one of the asyncio.Transport objects selected on the interface Listbox
  # - *args
  target.write((" ".join(args)).encode("utf8"))
  
kiface.commands["send"] = Send
kiface.Run()

Alias example

# ...
kiface.commands["helloworld"] = lambda interface, target, *args: Send(interface, target, "Hello World!")
kiface.Run()

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages