Code Monkey home page Code Monkey logo

sample-signalr's Introduction

Sample SignalR

This sample will show a variety of built in tools and techniques in MassTransit.

Requirements

A message broker. This sample provides a docker-compose.yml which uses RabbitMq (broker) and MsSql (db). If you have rabbitMq locally installed, you can skip the first step.

Easy Steps

  1. in the directory with the docker-compose.yml run the command docker-compose up -d
  2. After complete, give it a few seconds, and you can browse to http://localhost:15672, and view the rabbitmq management console
  3. go into the src/SampleSignalR.Service/ directory and type dotnet run --console
  4. in another command window, go into src/SampleSignalR.Mvc and type dotnet run --launch-profile sample1
  5. in a thihrd command window, go into src/SampleSignalR.Mvc and type dotnet run --launch-profile sample2
  6. Browse to http://localhost:5100
  7. In another browser tab, go to http://localhost:5200

Message from one tab to another, and console app

The reason we run two profiles is to simulate horizontal scaling. If you have two web hosts, any message sent on signalr backplane should be sent to all services on the backplane. And lastly, the console app can simulate a backend service that wants to send events directly to the SignalR javascript methods.

When you are all done, run docker-compose down

sample-signalr's People

Contributors

maldworth avatar phatboyg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sample-signalr's Issues

Suggestions for how to isolate messages for a single tenant web app when MassTransit uses multiple exchanges

In our existing RabbitMq implementations for a single tenant app, we isolate each web app to its own RabbitMq exchange so all messages belong to the same app. Building on Sample-SignalR chat example on a RabbitMq server hosting multiple apps, how can we isolate messages to a single app when Sample-SignalR creates multiple exchanges? Is the suggestion to use one virtual host per app?

With two web servers (both running on localhost) serving one app locally, MT creates 15 exchanges where we tried to isolate all communication within a single exchange.
image

How to send message to specific User by id?

I'm trying to send messages to connected users across multiple browser by using this following code as mentioned on docs

  await busControl.Publish<User<ChatHub>>(new
                {
                    UserId = 1,
                    Messages = protocols.ToProtocolDictionary("broadcastMessage", new object[] { "backend-process", "user id 1" })
                });

though sending to all or specific connection ids are working

 await busControl.Publish<All<ChatHub>>(new
                {
                    Messages = protocols.ToProtocolDictionary("broadcastMessage", new object[] { "backend-process", value })
                });              
              
               
                string cid = "A7axrqsCxdWXp6HydpNM-g";
                await busControl.Publish<Connection<ChatHub>>(new
                {
                    ConnectionId = cid,
                    Messages = protocols.ToProtocolDictionary("broadcastMessage", new object[] { "backend-process", value })
                });

All i want to send msg to specific user who having multiple connection ids. I didn't find any related docs for custom mapping while connecting to signalr hub.
How to map loggedin userid to signalr hub with masstransit so that i can use Publish<User> as working.
Any help regarding this.Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.