Skip to content

Generic event hub mainly for front end signalling if an asycnhronous task has completed in the backend

License

Notifications You must be signed in to change notification settings

sjefvanleeuwen/signalr-event-hub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SIGNALR Event Hub

Build Status Ask Me Anything ! PRs Welcome GPLv3 license Open Source Love svg2

Generic event messaging hub mainly for front end signalling if an asycnhronous task has completed in the backend. This runs via websockets. There are 3 websocket node types.

The main goal of this setup is to update the User Interface when tasks categorized in topics complete their work. Also live chat can be supported with this setup.

signalr-setup

  1. The SIGNALR Server contains a generic hub for multicasting topics to connected client.
  2. The SIGNALR Client Console publishes events on topics
  3. The SIGNALR Client Angular UI front end is the subscriber to these topic

Status

The project is under construction. The nodes currently show simple event messaging and CORS is currently setup.

Run this sample

Open three Terminals in VSCODE to run the three nodes.

~\signalr-event-hub\src\signalr-event-hubt>dotnet run
~\signalr-event-hub\src\signalr-test-client>dotnet run
~\signalr-event-hub\src\signalr-test-angular>dotnet run

Browse to http://localhost:5050

And choose the SignalR menu. You will see messages arriving from the client console.

signalr-setup

Angular Component (code listing)

import { Component, OnInit } from '@angular/core';
import { HubConnection, HubConnectionBuilder } from '@aspnet/signalr';

@Component({
  selector: 'app-signalr-topic',
  templateUrl: './signalr-topic.component.html',
  styleUrls: ['./signalr-topic.component.css']
})
export class SignalRTopicComponent implements OnInit {
  public hubConnection: HubConnection;

  ngOnInit(): void {
    const divMessages = document.querySelector("#divMessages");
    this.hubConnection = new HubConnectionBuilder()
      .withUrl("http://localhost:5051/eventhub")
      .build();
    this.hubConnection.start().catch(err => document.write(err));
    this.hubConnection.on("echo", (message: string) => {
      let m = document.createElement("div");
      m.innerHTML =
          '<div class="message__author">' + message + '</div>';
      divMessages.appendChild(m);
    });
  }
}

Built With

  • VSCODE - The IDE used
  • DOCKER - Build, Ship, and Run Any App, Anywhere

Contributing

Pull requests are accepted

Authors

  • Sjef van Leeuwen - Initial work - github

License

This project is licensed under the GPL-V3 License - see the LICENSE file for details

About

Generic event hub mainly for front end signalling if an asycnhronous task has completed in the backend

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published