コード例 #1
0
 /// <summary>
 /// The only unmanaged resource here is the connection, so get rid of them.
 /// </summary>
 /// <remarks>Call <see cref="Dispose"/> when you are finished using the <see cref="MyWebSocket.WebSocketSpinner"/>. The
 /// <see cref="Dispose"/> method leaves the <see cref="MyWebSocket.WebSocketSpinner"/> in an unusable state. After
 /// calling <see cref="Dispose"/>, you must release all references to the
 /// <see cref="MyWebSocket.WebSocketSpinner"/> so the garbage collector can reclaim the memory that the
 /// <see cref="MyWebSocket.WebSocketSpinner"/> was occupying.</remarks>
 public void Dispose()
 {
    if (connection != null)
    {
       connection.Dispose();
       connection = null;
    }
 }
コード例 #2
0
      public WebSocketSpinner(WebSocketClient supportingClient, WebSocketUser newUser, WebSocketSettings settings) 
         : base("WebsocketSpinner", settings.ShutdownTimeout)
      {
         connection = new WebSocketConnection(supportingClient, newUser, settings.LogProvider);
         this.settings = settings;

         //Fix up the user so it does what we want.
         User.SetSendPlaceholder((message) =>
         {
            if(connection.Client != null)
               connection.Client.QueueMessage(message);
         });
         User.SetCloseSelfPlaceholder(() =>
         {
            connection.Client.QueueRaw(WebSocketFrame.GetCloseFrame().GetRawBytes());
         });
      }