I am trying to use websocket-sharp to interface with a pro-presenter instance as a windows form app. I was able to get a similar project working with JavaScript. My .net version connects to the socket and runs the OnOpen event then immediately runs the OnClose event. Below is my code block. The e.Reason inside the OnClose event is blank. Where am I going wrong?
using (WebSocket ws = new WebSocket("ws://" + config.ComputerIP + ":" + config.Port + "/stagedisplay"))
{
ws.OnOpen += (sender, e) =>
{
// send connect string
ws.Send("{\"pwd\":\"" + config.Password + "\",\"ptl\":610,\"acn\":\"ath\"}");
};
ws.OnMessage += (sender, e) =>
{
slide.ProcessMessage(e.Data);
CurrentSlideLbl.Text = slide.CurrentSlide;
};
ws.OnClose += (sender, e) =>
CurrentSlideLbl.Text = "reason:" + e.Reason;
ws.OnError += (sender, e) =>
CurrentSlideLbl.Text = "Socket encountered error: Closing socket" + e.Message;
ws.Connect();
}