c# - Why does HttpContext.AcceptWebSocketRequest function make an error when it gets an instance? -


according samples in internet , this guide created connection of websocket .

public class sockets: ihttphandler {      public bool isreusable {         {             throw new notimplementedexception();         }     }     public void processrequest(httpcontext context) {         if (context.iswebsocketrequest) {             context.acceptwebsocketrequest(new sockethandler());         }     } }  public class sockethandler: websockethandler {      public sockethandler(): base(null) {} } 

there error in line-

context.acceptwebsocketrequest(new sockethandler()); 

the error:

argument 1: cannot convert 'sockethandler' 'system.func(system.web.websockets.aspnetwebsocketcontext,system.threading.tasks.task)'

can me?

the acceptwebsocketrequest takes method argument, not class instance. code should this:

public void processrequest(httpcontext context) {     if (context.iswebsocketrequest) {         context.acceptwebsocketrequest(handlewebsocket);     } }  private task handlewebsocket(websocketcontext wscontext) {     // useful } 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -