> For the complete documentation index, see [llms.txt](https://jen-hsuan-hsieh.gitbook.io/asp-net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jen-hsuan-hsieh.gitbook.io/asp-net/chapter2signalr/22basic-of-signalr/226creating-a-client-method-and-calling-from-server.md).

# 2.2.6.Creating a client method and calling from server

* 1.Modify the server method: call all the clients in server method

```
[HubName("myhub")]
public class MyHub:Hub
{
    public void serverMethod(string msg)
    {
        Clients.All.clientMethod(msg + " good morning");
        //return msg + " good morning";
    }
    public MyHub()
    {
        //
        // TODO: Add constructor logic here
        //
    }
}
```

* 2.Modify html file: remove the action if server method success

```
<script>
    $(document).ready(function () {
        var obj = $.connection.myhub;
        obj.client.clientMethod = function (data) {
            alert(data);
        }

        $.connection.hub.start().done(function () {
            obj.server.serverMethod("Hi");
        });
    });
</script>
```

* 3.Open few client and refresh one of them
  * All client will throw alert message
