SignalR Web Api

To test, simply open up Postman and do a POST to the following URL: http:///api/publish. The body of the POST should have the following object:

{ "ClientMethodName":"CallBatman", "Data":"some text message that should only call the clients CallBatman() event." }

The client application must have a method called "CallBatman", this message must accept the "Data" property which will be serialized. Client will be able to de-serialize the json object.

Below is a basic example of an HTML File accepting data from SignalR Web Api.

            <!DOCTYPE html>
            <html>
            <head>
                <meta charset="utf-8" />
                <title>SignalR Test</title>
            </head>
            <body>
                    <div id="result">
                       Post some data to the API and it will appear here!
                    </div>
        
                <!--Reference the jQuery library. -->
                <script
                        src="https://code.jquery.com/jquery-1.12.4.js"
                        integrity="sha256-Qw82+bXyGq6MydymqBxNPYTaUXXq7c8v3CwiYwLLNXU="
                        crossorigin="anonymous">
                </script>
    
                <!--Reference the SignalR library. -->
                <script src="https://ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-2.2.2.js"></script>
    
                <!--Reference the autogenerated SignalR hub script. -->
                <script src="signalr/hubs"></script>
    
                <script type="text/javascript">
                    $(function () {
                        var connection = $.hubConnection("http:///signalr", { useDefaultPath: false });
                        var hubProxy = connection.createHubProxy('syxHub');

                        hubProxy.on('TestMethod', function (data) {
                            console.log(data);
                            $('#result').text('This message was recieved from POSTMAN: ' + JSON.stringify(data));
                        });
          
                        connection.start()
                            .done(function () { console.log('Now connected, connection ID=' + connection.id); })
                            .fail(function () { console.log('Could not connect'); });
                    });
                </script>
            </body>
            </html>
        
{ "ClientMethodName":"TestMethod", "Data":"Here is your data posted from POSTMAN :)" }