0

Hi I am attempting to use websocket-sharp to open a socket to connect to my node.js backend, but I am running into a compiler error listed below. However, all the examples using websocket-sharp seem absolutely identical. I am at a loss at this point, and was hoping someone could point me in the right direction.

COMPILER ERROR Delegate System.Func' does not take2' arguments

    private void OpenSocket(string cmd){
        using (var websocket = new WebSocket ("ws://127.0.0.1:3000/socket.io/?EIO=2&transport=websocket")) {
            websocket.OnMessage += (sender, e) => websocket.Send ("Hi There");
            websocket.Connect();
            websocket.Send ("TEST");
            Console.ReadKey (true);
        }
    }

===Full Code=== https://gist.github.com/MicahRamirez/986f8168b9fa8c4c1e9e

===WebSocket-Sharp Ex Usage=== https://gist.github.com/MicahRamirez/0c23d6aa1b9bf8e5613aO

  • 1
    Shouldn't there be `{ }` brackets around the event handler code? – ChrisF Dec 23 '15 at 23:05
  • you are saying ` websocket.OnMessage += {(sender, e) => websocket.Send ("Hi There");};` ? That gives me a compiler error as well. Unexpected symbol "{" – Xavier Ramirez Dec 23 '15 at 23:15
  • No, `websocket.OnMessage += (sender, e) => { websocket.Send ("Hi There"); };` (But if this is C# 6 I could be wrong) – ChrisF Dec 23 '15 at 23:19
  • @ChrisF `{}` are not necessary in a single-statement lambda expression. – Jakub Lortz Dec 23 '15 at 23:26
  • It compiles fine for me. VS2015, .NET 4.6, new console app, install latest version of `websocket-sharp-with-proxy-support` from nuget, paste your code, add `using WebSocketSharp;`, compile. No errors. – Jakub Lortz Dec 23 '15 at 23:27
  • @XavierRamirez -- your second GIST link is not working properly. – David Tansey Dec 23 '15 at 23:28
  • @JakubLortz - I wasn't 100% sure which is why I asked it as a question. I put them in through force of habit. – ChrisF Dec 23 '15 at 23:30
  • @JakubLortz TY TY TY!!! I was using the package Websocket-sharp.clone instead of the one with proxy support. After changing that, I am all good. Thank you so much! – Xavier Ramirez Dec 23 '15 at 23:33

0 Answers0