how can i create a hub object in n layer architecture

236 Views Asked by At

currently, am working on client server application using 3 layer architecture, User interface, API and than agsxmpp Library.

Hubs are written in class library, I want to create the object of hub from front end. below is the script, I have included all the packages of signal r in both class library and asp.net web forms.

<script src="/signalr/signalr/hubs"></script>
<script type="text/javascript">
    $(function () {

        //how can I create the object of hub which exists in class library
        var connectionChat = $.connection.connectionChat;
        debugger;
    });
</script>

how can I create hub instance in three layer architecture

enter image description here

1

There are 1 best solutions below

1
Kelso Sharp On

You keep your owin in your class library, it should know where it is.

var connectionChat = $.hubConnection();
var chatProxy = connectionChat.createHubProxy('HubNameHere');

var message = 'message to be sent';

connectionChat.on('addMessageToPage', function(userName, message) {
console.log(userName + ' ' + message);

connectionChat.start();