self._name = f"{self._address}:{self._port}"
if path != '/':
self._name = path[1:]
- self._bus.register(self._name, [{}], [{}], self._receive)
+ self._bus.register(self._name, 'WSServer-Connection',
+ [{}], [{}], self._receive)
async def _receive(self, message: Message) -> None:
json_message = json.dumps(message)
return HTTPStatus.OK, response_headers, body
def _process_conf(self, conf: PluginConfiguration) -> None:
- if 'port' not in conf:
+ self._port = 80
+ if 'port' in conf:
+ self._port = conf['port']
+ else:
print(f"'port' not configured for WSServer '{self._name}'."
" Using 80.")
- conf['port'] = 80
- self._port = conf['port']
- if 'web root' not in conf:
+ web_root = 'web'
+ if 'web root' in conf:
+ web_root = conf['web root']
+ else:
print(f"'web root' not configured for WSServer '{self._name}'."
" Using 'web'.")
- conf['web root'] = 'web'
self._web_root = os.path.realpath(os.path.join(os.getcwd(),
- conf['web root']))
+ web_root))
super()._process_conf(conf)
async def run(self) -> None:
// Create section for client:
-function createForClient(client) {
+function createForClient(client, plugin) {
const section = document.createElement('section')
section.setAttribute('id', client)
section.setAttribute('class', 'client')
- const heading = document.createElement('h2')
- heading.appendChild(document.createTextNode(client))
+ const heading = document.createElement('header')
+ const headingH2 = document.createElement('h2')
+ headingH2.appendChild(document.createTextNode(client))
+ heading.appendChild(headingH2)
+ const headingH3 = document.createElement('h3')
+ headingH3.appendChild(document.createTextNode(plugin))
+ heading.appendChild(headingH3)
section.appendChild(heading)
const receiveOuter = document.createElement('div')
receiveOuter.setAttribute('class', 'interfacecontainer')
if (clientElement == null) {
// Create element for client if not existent:
const main = document.getElementById('ControlPi Debug')
- main.appendChild(createForClient(message['client']))
+ main.appendChild(createForClient(message['client'],
+ message['plugin']))
}
// Crate message elements for receives interface:
const receiveContainer = document.getElementById(message['client'] + ' Receives')
if (clientElement == null) {
// Create section for client if not existent:
const main = document.getElementById('ControlPi Debug')
- main.appendChild(createForClient(message.sender))
+ main.appendChild(createForClient(message.sender, ''))
}
// Update last received message:
const lastContainer = document.getElementById(message['sender'] + ' Last')