嗨,帮派,在此WebSockets教程中,我将向您展示如何向每个客户端广播消息,除了最初向服务器发送消息的客户端。这与从服务器发出消息相反,后者从服务器发出消息到每个单个客户端,包括最初发送消息的客户端。
—–课程链接:
+回购-https://github.com/iamshaunjp/websockets-playlist
+ Atom编辑器-https://atom.io/a
+下载节点-https://nodejs.org/en/
+ Socket.io-https://socket.io
————————————————– ——————————————-
相关教程:
—– NODE.JS教程
—–订阅频道-https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1
==============网络忍者=====================
有关更多的前端开发教程并精通您的编码技能,请访问-https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg或http://thenetninja.co.uk
==================社交链接==================
Twitter-@TheNetNinja-https://twitter.com/thenetninjauk
Short and sweet! Love it!
maybe keyup can emit an empty "typing" object with a setTimeout of 5 secs or so.
Thanks!
thank you very much… it is a great work! keep up
Could someone please explain how to create a non-localhost server? I want to use this on my actual website
Great teacher, I just subscribed!
Thanks a lot for these tutorials!
Incredible.
sir you are awesome
Another awesome tutorial from Shaun. When he has 10 million subscribers, I'll be able to say "I was watching him when he only had 300,000!" 🙂
If you want to send chat by hitting the 'enter' key…
let emitChat = function() {
socket.emit('chat', {
message: message.value,
handle: handle.value
});
message.value = '';
}
// emit events
btn.addEventListener('click', function() {
emitChat();
});
message.addEventListener('keydown', function(event) {
if (event.keyCode === 13) {
emitChat();
};
});
Awesome…now i know how web sockets works !! Thanks Net Ninja !!
what about private channels?
Great video, very well explained 🙂
You explain really good! Good Videos.
Great series
How do i emit message to specific socket like whatsapp, telegram etc.. Please make video on this.
Great series ! Thank you man !
Great job! Thanks Shaun! – Davis
but what if you start typing a message and delete it, great tutorial anyway
Could you use socket io connect and send to external websocket server ??
ex. client <—> server A <—-> server B
Thank you so much Net Ninja, is there any particular reason why you're still using old school javascript though? (non arrow functions/var)??
Would you let me know the font family and weight? I can’t find it 🙁