What’s the best design for a Spring Websocket multi channel chat app

I did the following tutorial about creating a very basic chat app by using Java Spring Boot and Websockets:

https://www.callicoder.com/spring-boot-websocket-chat-example/

Below are some fragments of the code:

src\main\java\com\example\websocketdemo\config\WebSocketConfig.java

package com.example.websocketdemo.config;  import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.web.socket.config.annotation.*;  @Configuration @EnableWebSocketMessageBroker public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {      @Override     public void registerStompEndpoints(StompEndpointRegistry registry) {         registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS();     }      @Override     public void configureMessageBroker(MessageBrokerRegistry registry) {         registry.setApplicationDestinationPrefixes("/app");         registry.enableSimpleBroker("/topic");   // Enables a simple in-memory broker     } } 

src\main\java\com\example\websocketdemo\controller\ChatController.java

package com.example.websocketdemo.controller;  import com.example.websocketdemo.model.ChatMessage; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.handler.annotation.Payload; import org.springframework.messaging.handler.annotation.SendTo; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.stereotype.Controller;  @Controller public class ChatController {      @MessageMapping("/chat.sendMessage")     @SendTo("/topic/public")     public ChatMessage sendMessage(@Payload ChatMessage chatMessage) {         return chatMessage;     }      @MessageMapping("/chat.addUser")     @SendTo("/topic/public")     public ChatMessage addUser(@Payload ChatMessage chatMessage,                                SimpMessageHeaderAccessor headerAccessor) {         // Add username in web socket session         headerAccessor.getSessionAttributes().put("username", chatMessage.getSender());         return chatMessage;     }  } 

src\main\resources\static\js\main.js (pseudo-code for simplicity)

var username;  function connect() {   username = getUsernameFromUI();   if (username) {       var socket = new SockJS('/ws');       stompClient = Stomp.over(socket);       stompClient.connect({}, onConnected, onError);   } }  function onConnected() {   stompClient.subscribe('/topic/public', onMessageReceived);   stompClient.send("/app/chat.addUser", {}, JSON.stringify({sender: username, type: 'JOIN'})); }  function sendMessage() {   var chatMessage = {     sender: username,     content: getMessageFromUI(),     type: 'CHAT'   };   stompClient.send("/app/chat.sendMessage", {}, JSON.stringify(chatMessage)); }  function onMessageReceived(payload) {     var message = JSON.parse(payload.body);     switch (true) {       case (message.type === 'JOIN'):         message.content = message.sender + ' joined!';         break;       case (message.type === 'LEAVE'):         message.content = message.sender + ' left!';         break;       default:         // nothing special here         break;     }     displayMessage(message); } 

Here there is a diagram related to the example above:

enter image description here

You can edit it through the following link (pencil icon on the bottom) (sorry the long url):

https://www.draw.io/?lightbox=1&highlight=0000ff&edit=_blank&layers=1&nav=1&title=Web%20Socket%20Diagram#R5Vpbd%2BI2EP41nNM8wLHlK49ASLPdbJvddC99FLbAaozlyiKB%2FfWVbMkXbHNpCCYNL1gjaSTP5ZvRWD1jslz%2FSmEcfCI%2BCntA89c947oHgG4MTf4nKJuM4tiSsKDYz0haQXjAP5Gcqagr7KNE0jISIyRkOK4SPRJFyGMVGqSUPFeHzUnoVwgxXKAa4cGDYZ36HfssyKiupRX0W4QXgVpZ12TPEqrBkpAE0CfPJZIx7RkTSgjLnpbrCQqF8KpyuWnpzTdGUcQOmfBl%2BPHh80%2F74xhN7%2Bcz5wYB%2Bq1vZ1yeYLiSL9wDdsj5jeeEs%2BW7ZhspCvufFVEd%2FSRV1IgP0O14XXTyp4X8T7nMqKI8xBRHCz7hO5olxHtEgvsojtVIvvFsyTYGUor5fgAlq8hH4u003v0cYIYeYuiJ3mdujJwWsGXIWzp%2FfEKUYa7WUYgXEacxEuc8RR9at4pVz5XFrRyRJWJ0w4fICZbSrzRw3ZQG%2FlyYi6WMIiiZijmUwofSRBc570KL%2FEEq8gilqpcoyQr53Kplk1AWkAWJYDgtqOOqNIsxd0RIKpXh34ixjXRRuGKkKmEuL7r5wRt9baAZivCXYDgwbEcRrtdyiay1KbfuEcVcBIhKYvYaYu%2B7lcNflayoh3bIxJXYAekCsR3jdLdZ2xSFkOGn6kZOrjm35o6fUJIIiALaLYz8ENEmx7iBwo9uvACyAfT9r0nzsJf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0AeZqnmMOC3Tg8RU57kIG%2BZ%2BgJ%2Fw%2FgM%2FyyRAydTQNmEZf9PYd0A8F1EU4WvR14A5icf3tBOUzswK2%2Bf2zEtg6dh1rnde6VGHW7xCu0g%2Bemo8T6SUimO717ISJaprSYUQiYSNzHIZbpMP9uyn0VVH%2BBAqxtw7JlmvXFGI2BD9wfPDjzeK%2BaOa5xa1bY%2Fov

My Question Is:

What would be the best design for a similar app if now I have the following requirements (similar to a typical chat app, for example: IRC):

  • there are multiple public channels (with N users at the same time) simultaneously
  • there are multiple private channels (with only 2 users) simultaneously
  • of course, private messages can only be read by the 2 involved users

If possible, please provide some code and if you provide some diagram that’s an extra bonus.

Thanks!

Cannabis Domains & Websites, YouTube Channel, Twitter Page, Daily Newspaper. Easy transfer.

VegasReputation.com
Cannabis Domains & Websites; YouTube Channel, Twitter Page, Daily Newspaper. Easy transfer.

CANNABIS BUSINESS FOR SALE OPPORTUNITY KNOCKS

Get your piece of the Las Vegas Legal Cannabis market w/the ONLY online…

Cannabis Domains & Websites, YouTube Channel, Twitter Page, Daily Newspaper. Easy transfer.

Is the capacity achieving input of a discrete memoryless channel unique?

Consider a classical discrete memoryless channel (DMC). Let $ p$ be an input probability distribution and $ Q$ be the channel’s transition matrix. $ q = Qp$ is a valid output probability distribution. The components of $ p$ and $ q$ are given as $ p_i$ and $ q_i$ respectively.

The capacity of this channel is given by maximizing the mutual information.

$ $ I = \max_{p}\left[\sum_ip_i\left(\sum_{j}Q_{ij}\log(Q_{ij})\right) – \sum_{j}q_j\log q_j\right]$ $

But, we know (Theorem 2.7.4 in Cover and Thomas, 2006) that $ I(p)$ is concave in $ p$ .

If $ I(p)$ is not simply a linear function (i.e. $ q = Qp$ is not a trivial relationship) and is differentiable everywhere (seems like a reasonable assumption), does this not imply that the capacity achieving $ p$ is unique?

YouTube channel has generated new email address – Google Analytics issues?

We created a second YouTube channel on a domain email account (e.g. info@domainname.co.uk), which we use as a central account for account access for our clients. However doing this suddenly created a brand account and our domain email address (e.g. info@domainname.co.uk) has now changed on the account to (infodomainname@gmail.co.uk), without alerting us to this change.

Now I am very concerned we will now lose access to all client accounts because of this change we were not aware of. When I go into settings it won’t let me change the main email address back to the domain one, but the domain email address is still being mentioned as getting alerts etc.

Right now it seems access still works and we can login with the domain email account credentials.

But can someone let me know if: 1. We will lose access to anything that granted us access to the domain email address soon (right now we haven’t but it has only just happened). 2. Will we not be able to login using the domain email address soon (right now we still can but it has only just happened). 3. Can we somehow get the domain email address back to the primary email address (as it won’t let us in account settings) – is this something we have to request from Google or go by another means?

Any advice would be much appreciated, as I am frightened we will lose all our access and permissions soon!

Automatically switch channel mode when headphones are plugged in?

I have an ASUS Xonar DGX soundcard. I was able to get audio playing out-of-the-box, however I am having issues with audio switching when headphones are plugged into the front panel.

I have plugged the “HD Audio” connector from my case directly into the soundcard. Previously, it was plugged into the motherboard and audio switching worked correctly, but I want to use the soundcard for the front panel audio.

I always have speakers plugged into the 3.5mm jack on the soundcard and somtimes have headphones plugged into the front panel 3.5mm jack.

If I open alsamixer, then I can toggle the “Analog Output” channel between:

  • “Stereo Headphones”
  • “Stereo Headphones FP”
  • “Multichannel”

enter image description here

  • If I select “Stereo Headphones”, then audio plays from the speakers.
  • If I select “Multichannel”, then audio plays from the speakers but much louder.
  • If I select “Stereo Headphones FP”, then audio plays from the headphones plugged into the front panel 3.5mm.

What I would like to achieve is when I plug headphones into the front panel, the audio is automatically switched to there. When I unplug the headphones, audio should be automatically switched back to the speakers.

I would also like to maintain separate volume levels for the two 3.5mm jacks.

I am using Ubuntu 18.04.2 LTS.

According to alsamixer I have 3 soundcards, but I only want to use [2] Xonar DGX.

Uploading same video on same channel but shorter

Running a YouTube jokes series, each video 15 minutes long. In each video, there are 10 categories (10 different “types” of jokes). Each category aims at different types of watchers, and each category has a name (lower third) so people can connect with it better.

From comments, it’s obvious that some people like one type of jokes (categories) and others like different ones. Usually, they write “that category is awesome, can’t wait for more”.

Videos we publish must stay in full length (15 mins) because of sponsorship, but for those people that come back and want to see all jokes in a specific category from all past videos, we would like to create playlists.

So, leaving the main videos as they are in full length, we are thinking about creating 10 playlists which would carry category names and uploading 1-2min. videos that are cut from the main video.

Would YouTube consider this spam?

How to get my phone to access WIFI channel 13?

My phone can’t see Wifi 2.4 Channel 13. Why? How can I fix it?

I have an android phone (Moto E4, Android 7.1.1, Not rooted) that was purchased in the US about 12 months ago. Just after purchase,I came to China for a few months, and it worked perfectly on the Wifi here in my home. I had a Chinese sim card. I don’t know what channel my home Wifi was working on last year.

In September, I returned to the US and swapped out the sim card for a US carrier. It continued to work perfectly.

I have just now returned to China, and my phone no longer can see the wifi signal in my home. When I look on my PC, it shows that the Wifi is transmitting on channel 13. When I look in my android app “Wifi Analyzer” it shows a blank space for channel 13. (Also, I forgot my Chinese sim card in the US)

Is this a hardware or a software issue? How to fix this?

Getting Name of MS Teams Channel Message Attachment

I’m trying to get the name of an attachment that was sent to my MS Team Channel’s email. It was posted as a message on the conversation board, which is how I’ve been referencing it.

Right now, I have the message attachment as a Current Item in my dynamic content, but I can’t figure out how to isolate just the attachment name. If I just print out the entire Current Item, I’ll get the following:

{“id”:null,”contentType”:”reference”,”contentUrl”:null,”content”:null,”name”:”Flow Request_2093811450.xlsx”,”thumbnailUrl”:null}.

I need some help splitting the string, so that I’m just getting the name field to print. Any help would be greatly appreciated!

Thank you