--- a/src/pyams_notify/event.py Tue Nov 20 17:50:37 2018 +0100
+++ b/src/pyams_notify/event.py Wed Nov 21 09:42:38 2018 +0100
@@ -12,26 +12,23 @@
__docformat__ = 'restructuredtext'
-
-# import standard library
import json
from datetime import datetime
-# import interfaces
+from pyramid.settings import asbool
+from transaction.interfaces import ITransactionManager
+from ws4py.client.threadedclient import WebSocketClient
+from zope.interface import implementer
+from zope.schema.fieldproperty import FieldProperty
+
from pyams_notify.interfaces import INotification, INotificationHandler
from pyams_security.interfaces import IPrincipalInfo
from pyams_security.interfaces.profile import IPublicProfile
+from pyams_security.utility import get_principal
from pyams_skin.interfaces.configuration import IBackOfficeConfiguration
-from transaction.interfaces import ITransactionManager
-
-# import packages
-from pyams_security.utility import get_principal
from pyams_utils.date import format_datetime
from pyams_utils.request import query_request
from pyams_utils.url import absolute_url
-from ws4py.client.threadedclient import WebSocketClient
-from zope.interface import implementer
-from zope.schema.fieldproperty import FieldProperty
@implementer(INotification)
@@ -114,7 +111,9 @@
handler = request.registry.settings.get('pyams_notify.tcp_handler')
if not handler:
return
- ws = WebSocketClient('ws://{0}/notify'.format(handler))
+ secure = asbool(request.registry.settings.get('pyams_notify.tcp_handler.secure'))
+ protocol = 'wss:' if secure else 'ws:'
+ ws = WebSocketClient('{0}//{1}/notify'.format(protocol, handler))
ws.connect()
try:
json_data = json.dumps(event, cls=NotificationEncoder)