0

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:

  1. How to identify right place to put code on server side?

  2. Should a port that I set in IIS to be different from WebSocket? May I set any port to WebSocket?

Thank you!

  • 1
    WebSocketSharp won't be able to host Websocket server in IIS. You might need to host it in a Windows Service. See https://stackoverflow.com/questions/35561343/how-to-host-websocket-sharp-server-on-iis. You can try to use ASP.NET SignalR for server side if possible. – AEonAX Sep 08 '17 at 06:37
  • Need to use asp.net websocket.. Thanks! – Dmitry Semin Sep 08 '17 at 07:32

0 Answers0