This article is a mirror article of machine translation, please click here to jump to the original article.

View: 179842|Reply: 47

[Source] .net/C# Using Websockets for Website Message Notifications [Source Code]

[Copy link]
Posted on 2/2/2018 5:58:01 PM | | |
Websocket is not much to say here, Xiao Zhazha has a post that has been introduced before, if you don't understand, you can Baidu or go to this post to see (.net/c# simulate websocket client connection [source code]
https://www.itsvse.com/thread-3652-1-1.html)。
Okay, not much to say, before the web message notification, I saw a lot of people using ajax rotation training to check, it was a bit of a waste of resources, and there were also long connections to do, I used WebSocket+iNotify.js.
iNotify.js is an encapsulated web message notification, which uses the Notification() API interface, which can pop up in the lower right corner when your website is minimized, which is very useful.
However, after version 62 in Google Chrome, the website needs to be https, which will be mentioned later.
It also uses a websocket heartbeat, which will ask the server for the data you need at a set time.
Okay, so much nonsense, post the code below, and attach it to the source code.
Client:
heartBeat.js  
Server:


ps: If you download the source code, it is best to deploy the web page to the local IIS to test, otherwise the pop-up window will not pop up, if you use it in the official project, you should pay attention to the Google Chrome restriction website mentioned earlier must be an HTTPS pop-up window will pop up,
Then if you want to implement the frontend on the Https site, use wss (var wsUrl = 'wss://127.0.0.1:4649'; The server side also needs to change the code accordingly, and it needs to be processed with the Https protocol, which I am still researching.
However, Firefox can be tested by other browsers in 360 speed mode.
If anyone has studied WSS, they can share it, study it, thank you.

Source code download:
Tourists, if you want to see the hidden content of this post, pleaseReply

Score

Number of participants1MB+1 contribute+1 Collapse reason
admin + 1 + 1 Very powerful!

See all ratings





Previous:Baidu Map JS retrieval control function
Next:Find high-end IT architects to work with
 Landlord| Posted on 2/2/2018 6:00:16 PM |
I found that I was distressed that JS was not finished, so I reposted it
heartBeat.js  

 Landlord| Posted on 2/2/2018 6:02:34 PM |
If you are testing locally, Google Chrome can also be used, and only if you publish the official website, Google will restrict it
 Landlord| Posted on 2/5/2018 9:11:50 AM |
Xiao Zhazha Posted on 2018-2-2 20:11
Microsoft has SignalR, why do you have to write it yourself?

Do your research
Posted on 2/2/2018 8:11:49 PM |
Microsoft has SignalR, why do you have to write it yourself?
Posted on 2/3/2018 2:08:06 PM |
Thank you for sharing, let's take a look
Posted on 2/5/2018 4:27:55 PM |
Yes, just in time
Posted on 3/7/2018 7:38:13 PM |
Do your research
Posted on 3/13/2018 5:13:03 PM |
sdfasdfasdfasfdasdfasdf

Score

Number of participants1MB-1 contribute-1 Collapse reason
QWERTYU -1 -1 Do not pour water, improving the quality of reply posts is the duty of every member.

See all ratings

Posted on 3/14/2018 2:17:43 PM |
Quite familiar, do you have to charge?
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com