Update the Needletail.MVC package before run the project.
The sample uses angular.js
Look how the SendMessageTo method on ChatController makes javasript call
public TwoWayResult SendMessageTo(string messageTo, string message)
{
dynamic call = new ClientCall { ClientId = messageTo, CallerId = User.Identity.Name };
//make the remote call
call.messageReceived(User.Identity.Name, message , true);
return new TwoWayResult(call);
}
The "messageReceived" function is defined in the Chat.js file, you can call js funcions defined anywhere in your javascript, you can also make calls to functions contained in a namespace like this:
dynamic call = new ClientCall { ClientId = messageTo, CallerId = User.Identity.Name };
//make the remote call
call.sample.of.namespace.call(parameter1, parameter2, etc);
return new TwoWayResult(call);
You can call javascript code anywhere in your server's code, i.e. you don't need to call as an ActionResult inside a controller
Take a look to To the RemoteController, there is a method in there that is called from the UserHelper class when a user logs in or logs out
The code that makes client calls does not need to be in the RemoteController
public static void ReloadUserList()
{
dynamic reload = new ClientCall { CallerId = string.Empty, ClientId = string.Empty };
reload.getUsers();
RemoteExecution.BroadcastExecuteOnClient(reload);
}
The "getUsers" method is defined also in the Chat.js file.