title: Using Static Wrapper Class
body: <p>In my search for a WebSockets library, I came across <a href="http://websockets.esegece.com/" rel="nofollow">this website</a> that provides Delphi and C# versions in download section. It grabbed my attention especially because the client-side of my application is developed using Delphi, and I'm trying to develop the server-side using C#.</p>
  
  <p>Looking at the Chat sample for C#, I realized that it uses a wrapper class (sgcWebSocketLib) around the unmanaged DLL written in Delphi. Here is an excerpt from sgcWebSocketLib.cs:</p>
  
  <pre><code>public sealed class sgcWebSocketLib
      {
          private static volatile sgcWebSocketLib instance;
          private static object syncRoot = new Object();
  
          private sgcWebSocketLib() 
          { 
          }
  
          public static sgcWebSocketLib Instance
          {
              get
              {
                  if (instance == null)
                  {
                      lock (syncRoot)
                      {
                          if (instance == null)
                              instance = new sgcWebSocketLib();
                      }
                  }
  
                  return instance;
              }
          }
  
          ... //the rest is omitted 
  }
  </code></pre>
  
  <p>and the code from Start button in Chat server (a typical WinForms application):</p>
  
  <pre><code>private void btnStart_Click(object sender, EventArgs e)
  {
            string vOptions = "";
            ... //setting options according to UI values
            sgcWebSocketLib.Instance.Server_LoadOptions(vOptions);
            sgcWebSocketLib.Instance.Server_Start();
  }
  </code></pre>
  
  <p>Now, here is the actual question: this Chat server uses a <code>static</code> property of sgcWebSocketLib class, and starts sending/receiving WebSocket stuff. Can I use the same approach in an ASP.Net application (WebForms or MVC)? Can I write the Chat server in ASP.Net using this wrapper class?</p>
  
  <p>PS: I know there is SignalR and maybe others. But it has some limitations (IIS 8, Windows Server 2012 requirement for WebSocket) beside the unanswered communication problem with a Delphi VCL client.</p>