Paolo ponzano - 64 - Sep 5, 2014

Excuse me Demis, what I’ ve to do in order to serve the ss-utils.js on an ASP.Net MVC application? have I to register an axd or something like this? Thanks

You don’t have to do anything. ss-utils.js is embedded in ServiceStack.dll and always accessible from /js/ss-utils.js from where ServiceStack is mounted which when using SS with MVC is typically at /api/js/ss-utils.js, e.g:

paolo ponzano:

Thanks a lot for your reply… I was missing the use of @Url.Content("~/api/…")… another question regarding the message receive…  I need to notificate the client in order to wake up some widget after a NotifyWidgets action has been invoked…  since only the widget of the current session needs to be notified I’ve used this method on my Controller

public ActionResult NofityWidgets()
            IServerEvents ServerEvents = AppHost.Instance.TryResolve<IServerEvents>();

            ServerEvents.NotifySession(UserSession.Id, “test”);
            return new EmptyResult();

and in my _Layout.cshtml I’ve

        $(document).ready(function (e) {
            var source = new EventSource("@Url.Content("~/api/event-stream?channel=channel&t=’+ new Date().getTime())")");

                handlers: {
                    onConnect: function (subscription) {
                        activeSub = subscription;
                    onJoin: function (user) {
                    onLeave: function (user) {
                    //… Register custom handlers
                receivers: {
                    //… Register any receivers
                success: function (selector, msg, json) { // fired after every message
                    console.log(selector, msg, json);

How do I process the received message? I don’t see any event fired when I receive a message


Hi Paolo, if your question has code please post it on and paste a link to it here as it’s unreadable otherwise.

If you want to notify  a SessionId you have to send the Permanent Session Id (ss-pid) which happens when the user authenticates with RememberMe=true. You can check if it’s the same by comparing UserSession.Id with the users ss-pid cookie. Because of this it’s more reliable notifying the user with the UserAuthId. You can also make use of a unique channel name to filter what messages a User listens to/receives.

paolo ponzano:

Hello Demis, my problem is related on the javascript part… how do I read the message I’ve sent from server?

Please see the docs, here’s the section on handling msgs with the default selector: