Skip to content

Instantly share code, notes, and snippets.

@thecopy
Created June 4, 2013 21:23
Show Gist options
  • Save thecopy/5709721 to your computer and use it in GitHub Desktop.
Save thecopy/5709721 to your computer and use it in GitHub Desktop.
public class SessionHandlerPipelineModule : HubPipelineModule
{
private readonly ISession _session;
private ITransaction _transaction;
public SessionHandlerPipelineModule(ISession session)
{
_session = session;
}
protected override bool OnBeforeConnect(IHub hub)
{
var baseHub = hub as BaseHub;
if (baseHub != null)
{
baseHub.Session = _session;
_transaction = _session.BeginTransaction();
}
return base.OnBeforeConnect(hub);
}
protected override bool OnBeforeDisconnect(IHub hub)
{
if(_transaction != null)
_transaction.Commit();
return base.OnBeforeDisconnect(hub);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment