带有演示者舞台显示的 websocket-sharp
websocket-sharp with pro-presenter stagedisplay
我正在尝试使用 websocket-sharp 作为 windows 表单应用程序与专业演示者实例进行交互。我能够使用 JavaScript 获得一个类似的项目。我的 .net 版本连接到套接字并运行 OnOpen 事件,然后立即运行 OnClose 事件。下面是我的代码块。 OnClose 事件中的 e.Reason 为空。我哪里错了?
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();
}
经过大量故障排除后,我弄明白了。这是我试图打开连接的方式。
WebSocket ws = new WebSocket("ws://" + config.ComputerIP + ":" + config.Port + "/stagedisplay");
ws.OnMessage += (sender, e) =>
{
slide.ProcessMessage(e.Data);
CurrentSlideLbl.Invoke(new Action(() => CurrentSlideLbl.Text = slide.CurrentSlide));
};
ws.OnOpen += (sender, e) =>
{
// send connect string
ws.Send(JsonConvert.SerializeObject(new { pwd = config.Password, ptl = 610, acn = "ath" }));
};
ws.OnClose += (sender, e) =>
{
CurrentSlideLbl.Text = "reason:" + e.Reason;
};
ws.OnError += (sender, e) =>
{
CurrentSlideLbl.Text = "Socket encountered error: Closing socket" + e.Message;
};
ws.Connect();
我正在尝试使用 websocket-sharp 作为 windows 表单应用程序与专业演示者实例进行交互。我能够使用 JavaScript 获得一个类似的项目。我的 .net 版本连接到套接字并运行 OnOpen 事件,然后立即运行 OnClose 事件。下面是我的代码块。 OnClose 事件中的 e.Reason 为空。我哪里错了?
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();
}
经过大量故障排除后,我弄明白了。这是我试图打开连接的方式。
WebSocket ws = new WebSocket("ws://" + config.ComputerIP + ":" + config.Port + "/stagedisplay");
ws.OnMessage += (sender, e) =>
{
slide.ProcessMessage(e.Data);
CurrentSlideLbl.Invoke(new Action(() => CurrentSlideLbl.Text = slide.CurrentSlide));
};
ws.OnOpen += (sender, e) =>
{
// send connect string
ws.Send(JsonConvert.SerializeObject(new { pwd = config.Password, ptl = 610, acn = "ath" }));
};
ws.OnClose += (sender, e) =>
{
CurrentSlideLbl.Text = "reason:" + e.Reason;
};
ws.OnError += (sender, e) =>
{
CurrentSlideLbl.Text = "Socket encountered error: Closing socket" + e.Message;
};
ws.Connect();