嗨,幫派,在此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 🙁