support@site.it +1 400 3113 11

WebSocket Server

PURE template has webSocket server (WSS). WSS are used as notification controller. What does it mean? First, WSS doesn’t send “big” data, like content (comments, activities and etc.) – WSS sends only notifications about some events on server – not more. Second, WSS do own authorization of users. WSS does nothing else.

To understand how it works, please, pay your attention on next scheme.

0

[total]

So, there are a few simple steps:

  1. User adds a new comment (for example in some post) and client sends request to server.
  2. API controller works on a request and makes necessary changes into database (add comment).
  3. API controller creates and adds into database webSocket event. This is just data about: where (postID in out example), what (a new comment) and when (date of comment) was happened.
  4. API controller sends response to client with confirmation of operation.

As you see during an action (adding comment) server did not send any notifications via WSS, just saved an information about such action (event) into database. Time to go on the next step.

0

[total]

Client receives confirmation about successful operation. And at this moment client sends command “wake up” to WSS. Pay your attention, client sends just command without any information, because all necessary information is in database. What does WSS?

  1. WSS reads all pending events from database.
  2. Check list of recipients (who is online right now) of each event;
  3. Send to each recipient package with data from event (in JSON format).

That’s all. Clients get such package and should decide what to do next: make some request to server (for new comments in post or for new messages in chat and etc.) or, maybe, do nothing. Job of WSS only say: “we have something new here” and nothing more.

Why we’ve chosen such scheme? Answer is very simple – to minimize a burden on WSS and … Yes one more important moment – to make universal mechanism of communication. WSS does not have any handles for some situations. WSS only reads and sends events – nothing more. And it allows to developers use WSS in own projects. Everything what developer needs – save event in database (sever part), call wakeup command (client part) and make handle for event on client part (a reaction of client on event).

The community

A community is a social unit of any size that shares common values. Although embodied or face-to-face communities are usually small, larger or more extended communities such as a national community, international community and virtual community are also studied.

Best of us

Copyright © 2015 Pure Theme. All Rights Reserved. Powered by WordPress.

Last posts

What is a template?

2015-06-09 22:47 / Jack Clark

Activate and deactivate theme

2015-06-09 22:46 / Jack Clark

What is provider?

2015-06-09 22:45 / Gabriel Thompson

The best way to add new front-page?

2015-06-09 22:44 / Gabriel Thompson

Where I can place my JS file?

2015-06-09 22:43 / Gabriel Thompson

Thumbnail for post

2015-06-09 22:43 / Gabriel Thompson

What is a component?

2015-06-09 22:41 / Jack Clark

About cache system

2015-06-09 22:29 / Jack Clark

WebSocket server

2015-05-30 00:34 / Gabriel Thompson

Test of question

2015-05-29 12:13 / Gabriel Thompson

Members

Groups

Tags

business (1)

cities (1)

Europe (1)

Categories

SandBox (1)

Countries (2)

Photos (2)

Music around (4)

Developer (10)

Cities (24)

The pure

Login or email

Password

The pure

Your login

Your email

The pure

Sorry, but at current time registration is unavailable.