Skip to content

Commit

Permalink
Merge pull request #128 from darkl/master
Browse files Browse the repository at this point in the history
Small refactor for #126
  • Loading branch information
statianzo committed Feb 24, 2015
2 parents 788daae + 6701509 commit 5c09198
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Fleck/WebSocketConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ private Task Send<T>(T message, Func<T, byte[]> createFrame)
{
const string errorMessage = "Data sent while closing or after close. Ignoring.";
FleckLog.Warn(errorMessage);
return Task.Factory.StartNew(() => { throw new ConnectionNotAvailableException(errorMessage); });

var taskForException = new TaskCompletionSource<object>();
taskForException.SetException(new ConnectionNotAvailableException(errorMessage));
return taskForException.Task;
}

var bytes = createFrame(message);
Expand Down

0 comments on commit 5c09198

Please sign in to comment.