-
Notifications
You must be signed in to change notification settings - Fork 3
/
SignalRExample.py
41 lines (27 loc) · 1.03 KB
/
SignalRExample.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from pysafeguard import *
import json
import time
# The appliance host name or IP address
hostName = ''
# The user name for password authentication
userName = ''
# The password for password authentication
password = ''
# Path to the trusted root ca of the appliance
caFile = ''
# Path to the .pem file for certificate authentication
userCertFile = ''
# Path to the corresponding .key file for certificate authentication
userKeyFile = ''
print('Connecting to Safeguard')
connection = PySafeguardConnection(hostName, caFile)
# SignalR callback function to handle the signalR messages
def signalrcallback(results):
print("Received SignalR event: {0}".format(results[0]['Message']))
print("Connecting to SignalR via username/password")
connection.register_signalr_username(connection, signalrcallback, userName, password)
time.sleep(30)
print("Connecting to SignalR via certifacte")
connection.register_signalr_certificate(connection, signalrcallback, userCertFile, userKeyFile)
print("wait 30 seconds to try out signalR")
time.sleep(30)