SHARE
TWEET

Untitled

a guest Aug 17th, 2018 398 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (env.IsDevelopment()) {
  2.     app.UseDeveloperExceptionPage();
  3. }
  4.             try
  5.             {
  6.                 // Set the WebSocket events.
  7.                 var username = "[user]";
  8.                 var password = "[password]";
  9.                 var ws = new WebSocket("ws://[IP]/rest/subscribe", "ISYSUB");
  10.                 ws.Origin = "com.universal-devices.websockets.isy";
  11.                 ws.SetCredentials(username, password, true);
  12.  
  13.                 ws.OnOpen += (sender, e) =>
  14.                 {
  15.                     Console.WriteLine("ONOPEN");
  16.                 };
  17.  
  18.                 ws.OnMessage += (sender, e) =>
  19.                 {
  20.                     Console.WriteLine("ONMESSAGE: " + e.Data);
  21.                 };
  22.  
  23.                 ws.OnError += (sender, e) =>
  24.                 {
  25.                     Console.WriteLine("ONERROR: " + e.Message);
  26.                 };
  27.  
  28.                 ws.OnClose += (sender, e) =>
  29.                 {
  30.                     Console.WriteLine("ONCLOSE");
  31.                 };
  32.                 // Connect to the server.
  33.                 ws.ConnectAsync();
  34.             }
  35.             catch(Exception e)
  36.             {
  37.                 Console.WriteLine("ERROR " + e.Message + " : " + e.InnerException + " : " + e.Data);
  38.             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top