Skip to content

galenp/SignalR.EventStream

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 

Repository files navigation

SignalR.EventStream

SignalR.EventStream was born out of a desire to monitor my websites for activities that I was interested in. User signups, logins, errors, anything really. SignalR from David Fowler and Damian Edwards has made that nice and easy.

Page specific streams

If you'd like to update a specific page (for any connected client) such as adding new comments or updating a view count. This utilizes the path information from the url to determine the group this connection belongs to.

<script type="text/javascript">
    $(function () {
        var stream = new PageStream().connect();
        //this would be the same as calling
        // var stream = new EventStream(window.location.pathname).connect();

        stream.eventReceived = function (type, data) {
            var li = $("<li>");
            li.html(data.Message);
            li.appendTo("#messages");
        };
    });
</script>
<ul id="messages"></ul>

You can then send a message to anyone subscribed to this page via the route path.

new EventStream().SendTo("/home/index", "status-update", new { Message = "some message" });

Group specific streams

Similar to above however instead of using PageStream() you would use EventStream(groupName).

<script type="text/javascript">
    $(function () {
        var stream = new EventStream("messages").connect();
        //this would be the same as calling
        // var stream = new EventStream(window.location.pathname).connect();

        stream.eventReceived = function (type, data) {
            var li = $("<li>");
            li.html(data.Message);
            li.appendTo("#messages");
        };
    });
</script>
<ul id="messages"></ul>

You can then send a message to anyone subscribed to this page via the route path.

new EventStream().SendTo("messages", "status-update", new { Message = "some message" });

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 75.1%
  • JavaScript 13.1%
  • Puppet 11.8%