<script type="text/javascript">
$(document).ready(function () {
var obj = $.connection.myhub;
obj.client.sayClient = function (msg)
{
alert(msg);
}
obj.client.clientmethod = function (data) { alert(data) }
$.connection.hub.start().done(function () {
obj.server.getName('Hi')
}).fail(function () { alert('not connected') })
});
</script>
[HubName("myhub")]
public class MyHub : Hub
{
public void GetName(string msg)
{
Clients.All.clientmethod(msg + " Visvesan");
}
public void MethodTest(string Test = "Hi Vishnu")
{
GetName(Test);
}
}
public class Admin
{
public static void Notify(string msg)
{
var AllContexts = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
AllContexts.Clients.All.sayClient(msg);
}
}
No comments:
Post a Comment