I have a desktop application (WPF) and a web application (ASP.Net) and want to set connection using WebSocket-Sharp.
On client side:
using (var ws = new WebSocket("ws://localhost:8085"))
{
var data = new byte[] { 1, 2, 3, 4, 5 };
ws.OnMessage += (send, args) =>
{
Status = "WebSocket. OnMessageEvent!";
};
ws.Connect();
if (ws.IsAlive)
{
ws.Send(data);
}
ws.Close();
}
On server side:
var wssv = new WebSocketSharp.Server.WebSocketServer("ws://localhost:8085");
wssv.Start();
wssv.AddWebSocketService<Chat>("/Chat");
Chat is a class that inherites WebSocketBehavior class.
There are two questions:
How to identify right place to put code on server side?
Should a port that I set in IIS to be different from WebSocket? May I set any port to WebSocket?
Thank you!