I have an implementation of the PersistentConnection
class in Signalr. For our site, I need to be able to broadcast a message, and then have each connection determine whether that particular message is relevant for that specific user before sending it down the pipe to the browser.
Something like this:
public class MyConnection : PersistentConnection {
private int _UserID;
public override void OnSending(object message) {
var msg = message as MyNotification;
if(msg != null && !msg.CanRead(_UserID))
return;
base.OnSending(message);
}
}
Is this possible?
Right now, we have a custom session state object. Upon connection, the id is added to the users session object. When we have a message to send out, we raise an event and each session determines whether to pass the message along to its associated client ids. I really want to decouple this from our session object.