3

Is it possible to combine upshot/knockout with signalr (I can only find questions about knockout and signalr only)? For example if I add a Task using:

    self.addTask = function () {
        var task = new Task({
            LastUpdated : new Date().toMSJSON(),
             Title : this.newTaskText(),
             IsDone : true
         });
         self.tasks.unshift(task);
    }

in the view model, this will add it to the view automatically (based on the knockout data binding) and call:

        public void InsertTask(Task task)
        {
            InsertEntity(task);
        }

in the server. What if I also want to broadcast this to other clients.. is it possible using the same libraries? If it is.. what changes should I have to do / additional things I need to do? Are there any alternatives that will make this easier but still following the upcoming Microsoft ASP.NET MVC 4 stack?

user1167132
  • 31
  • 1
  • 3

1 Answers1

1

You should be able to, On the server you can call

var connection = AspNetHost.DependencyResolver.Resolve<IConnectionManager().GetConnection<MyConnection>();
connection.Broadcast("Called from an mvc controller or server side method");

Or you could create a hub and implement it client side in the function:

 self.addTask

to send a "addTask" message to clients.

Elliot Wood
  • 964
  • 1
  • 9
  • 29