Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (env.IsDevelopment()) {
- app.UseDeveloperExceptionPage();
- }
- try
- {
- // Set the WebSocket events.
- var username = "[user]";
- var password = "[password]";
- var ws = new WebSocket("ws://[IP]/rest/subscribe", "ISYSUB");
- ws.Origin = "com.universal-devices.websockets.isy";
- ws.SetCredentials(username, password, true);
- ws.OnOpen += (sender, e) =>
- {
- Console.WriteLine("ONOPEN");
- };
- ws.OnMessage += (sender, e) =>
- {
- Console.WriteLine("ONMESSAGE: " + e.Data);
- };
- ws.OnError += (sender, e) =>
- {
- Console.WriteLine("ONERROR: " + e.Message);
- };
- ws.OnClose += (sender, e) =>
- {
- Console.WriteLine("ONCLOSE");
- };
- // Connect to the server.
- ws.ConnectAsync();
- }
- catch(Exception e)
- {
- Console.WriteLine("ERROR " + e.Message + " : " + e.InnerException + " : " + e.Data);
- }
Add Comment
Please, Sign In to add comment