473,471 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A good WebSocket design

4 New Member
Do you want to developing once can be used by many another places? Do you want your function can be supported either by android,IOS or desktop?

At the begin of design, you need to consider those things. The first thing you may figure out is using html5 to developing.

It a good new that WebSocket standard is supported by html5 and also supported by so many main aspect Browsers broad.

For a kind of broadcast requirement we can use some client plugins to effectively communicate with servers. For some light level functions like comment we need to add too heavy plugins to ours' application. So WebSocket is a better solution for us.

The simplest design
One javascript WebSocket client plugin in browser and a WebSocket server technology like Spring. In Spring you can create a controller to receive the message and send message to Browser. But this is a hello world level design. It just only to use to study the WebSocket skill or do some very simple applications.

A better solution that can be shared
For server-side, we can design a independent layer that just only too use to connect client and transfer message. This layer does not need to implement some business requirement. So this layer can be reused by many kinds of business requirement at the same time, it's a realtime communication layer that service the same situation for many difference business requirement.

1, When starts a Browser that sends a request to WebSocket Server and then connects to the WebSocket Server, this connection isn't close before the Browser is closed.

2,Sends a business request to the Business Server, If the user isn't login in will be redirected to login in login page, otherwise the request go to the server, the server will record the user's information or retrieve the user's information from database that it's recorded in after the user complete register. This user will send this piece of request message to a Message Queue server, The WebSocket Server have subscribed this Message Queue's Topic, As soon as the Message Queue Server receive this kind of message the WebSocket Server will receive the message. Then the WebSocket Server sends this message to all of client or special client which is connecting.

Let start a really business requirement

We need to implement a comment and chat function. The login user can comment something to a article. All of user can communicate each other in real time. This function consists two blocks, one is font page that is for general user, the other is backend management system, manager of this system can reply to some special users from backend page.

Implement
1,We need to design a database table that record register users or chat users, the table have a column that stores a communication room number or communication topic.
2,Browser client sends a request with some parameters that include user's name and communication room or communication topic to business server.
3, Retrieve a token from business server. The token is used to verify in WebSocket Server. This token need have some business information that can be recognized by WebSocket Server.
3,Browser client sends a another request to WebSocket Server take along that token.Making a long connection with WebSocket Server.
4,Browser client invoke Business Server Interface for send chat message and at the same time the request with communication room or communication topic.
5,The Business Server find user list from database according to communication room or communication topic.
6,The Business Server constructs Queue Message and then send the message to Message Queue Server.
7,WebSocket Server send the message that have subscribed from Message Queue Server to receive user list that also from Message Queue Server.

Implement of Backend Server just need to retrieve from receiving users and construct message and then send to Message Queue Server, and the other parts is the same.
Aug 6 '17 #1
0 3142

Sign in to post your reply or Sign up for a free account.

Similar topics

30
by: Christian Seberino | last post by:
How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python? Python's design is godly. I'm wondering if Ruby's is godly too. I've heard it has solid OOP design but then...
36
by: toedipper | last post by:
Hello, I am designing a table of vehicle types, nothing special, just a list of unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor etc etc For the table design I am...
1
by: Nick Farina | last post by:
I am beginning work on what will be a rather large .NET application. I have a treeview that I would like to be very "intelligent" in that it represents some program data and automatically updates...
1
by: John | last post by:
Using these tables as an example, where the first key is the Primary Key and subsequent keys are Foreign Keys: tbl_A, PrimaryKey_A tbl_B, PrimaryKey_B, PrimaryKey_A tbl_C, PrimaryKey_C,...
3
by: Rob Thomas | last post by:
Hi, I'm just getting started with real OO design and programming and am after a little advice. Basically, I've got a Customer class and an Agency class. The Agency class inherits all the...
50
by: Jay Balapa | last post by:
Hello, Currently my application has three tiers- 1. Presentation Layer (Asp.Net / Win Forms/ Pocket PC UI.) This predominantly contains User Controls, Custom Controls and Win/Web Forms. I...
0
by: WebCM | last post by:
I hope you can spend some time and help me to select proper application design and programming issues. :) I'm making new version of CMS. I've been mostly theorizing about it for a recent months. ...
2
tharden3
by: tharden3 | last post by:
What are some good color combinations for web design in your opinion? I was thinking about a bumble design for my newest page. It'd be mostly black with a bunch of nice touches of yellow here and...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.