Created
June 4, 2013 21:23
-
-
Save thecopy/5709721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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