r/learnwebdev • • Jun 19 '20

Websockets Help

4 Upvotes

Hello, I am building an app with websockets and could use some guidance

The app itself is a real time feed/ticket + chatroom. So essentially at the top of the screen will be a rolling feed of data (the feed itself is powered by a service/script that writes to the socket directly which then writes it out to the client) and then the bottom half is a chat room.

Right now the way I have it set up is

Client:

var chatWS = new WebSocket("ws://url.com:port/chat")
chatWS.onmessage = function(event) { // parse event + render }

var feedWS = new WebSocket("ws://url.com:port/feed")
feedWS.onmessage = function(event) { // parse event + render }

Server (pseudo code):

app.GET("/chat", chatWSRoute)
app.GET("/feed", feedWSRoute)


function chatWSRoute(req, resp) {

// upgrade connection websocket

// add the "client" (aka who connected) to the list of conns

// wait for users to send messages, once received, broadcast to all clients
}

function feedWSRoute(req, resp) {

// upgrade connection to websocket

// add a list of clients, ignore any messages sent from the web side

// read messages written to the socket from a seperate service and broadcast to all ui sockets 
}

Service (pseudo code):

function() {

// connect to websocket

// doSomeLongRunningTaskToGatherData

// stream + write messages to the socket, dont worry about reading
}

Is this the right approach? As in, having 2 seperate websocket routes to manage the feeds vs the chat? Is there a way to combine it into 1 websocket route or any suggestions? Before anyone says socketio or anything else, I need to stick to websockets for this specific task. The way I have it setup works (i can send messages/see other user messages while also getting a rolling feed) but wasn't sure if this was the "efficient" way to do websockets


r/learnwebdev • • Jun 07 '20

How to get to know developers???

4 Upvotes

I've been studying webdev for a month now, everybody tells you that you should build a network of people and friends interested in it too, but I don't know nobody. Any tips? (:


r/learnwebdev • • Jun 01 '20

A mental model for choosing technology

Thumbnail
medium.com
4 Upvotes

r/learnwebdev • • May 29 '20

Build and Deploy a React PWA - Why Progressive Web Apps are the Future of the Web

Thumbnail
youtu.be
4 Upvotes

r/learnwebdev • • May 24 '20

How does one go about adding freemium features to a website?

4 Upvotes

I am looking to build a website that will offer users digital products that can be unlocked through a monthly subscription. I have done Android Development in the past and I know the way to do it there is through Google Play services which helps with payments, store managements etc.

For web what is the best way to do it? I am using Vue with a Firebase back-end. I have quite a bit of experience with software engineering but am absolutely a noob at with everything related to payments.


r/learnwebdev • • Apr 19 '20

Programming / IT audiobooks

4 Upvotes

Hi everyone,

I would like to spend more time learning from field-related books, and I was wondering if there are any good audiobooks available. I want to listen to something while jogging so might as well be study-related. What are your recommendations? (Books but also platforms, I had Audible years ago and I remember that it had only few books related to CS/programming.)

All suggestions are welcome, although I am currently studying my Master's.


r/learnwebdev • • Apr 10 '20

How to work with CSV files in Python

Thumbnail
youtu.be
4 Upvotes

r/learnwebdev • • Apr 06 '20

Quickly Improve Your Docker and Node.Js Containers

Thumbnail
medium.com
4 Upvotes

r/learnwebdev • • Mar 23 '20

What do they mean by PHP "or other"? What languages are those other? I mean i am learning web development and i already have i little bit of background in Python and C++, could these languages be used?

Post image
4 Upvotes

r/learnwebdev • • Mar 03 '20

Dockerize a React App and an Express API With MongoDB

Thumbnail
medium.com
4 Upvotes

r/learnwebdev • • Feb 08 '20

Best Web Development Tutorials on YouTube

Thumbnail
techjasmine.com
4 Upvotes

r/learnwebdev • • Jan 20 '20

How to Make Interesting Presentations for Software Projects

Thumbnail
scenelab.io
4 Upvotes

r/learnwebdev • • Jan 15 '20

Best Books To Learn Web Development: From Newbie To Advanced - Level Up Dev

Thumbnail
levelupdev.co
4 Upvotes

r/learnwebdev • • Jan 08 '20

Would you be interested in learning web development by working on the real-world programming tasks?

Thumbnail self.learnprogramming
4 Upvotes

r/learnwebdev • • Dec 10 '19

Hello Friends, I am working on weekly course on Quasar framework. I am looking for feedback on the video tutorials. Thanks in advance for your feedback and helping me to share my knowledge with wider tech community.

Thumbnail
youtube.com
4 Upvotes

r/learnwebdev • • Nov 25 '19

Learning to create a website as a resume?

4 Upvotes

Currently a second year at a uni in california. I have been applying to internships recently and noticed that most of them want/require previous expierience with at least front end web developement. So I have decided to create a website about me and my projects to show that I have something to work towards. Currently I have been learning C++ at my school mainly because it is the main language taught. Next semester I will be working in a lab that uses python for all of its developement. As for now though, I am planning to learn javascript.

The main issue is that I don't know what resources to look into. The main one I have found was w3schools and TheOdinProject, they seem promising but I thought i'd ask before I start going down one of those paths


r/learnwebdev • • Nov 03 '19

What next

4 Upvotes

I have learned html and css and i want to build a website but before that one i think i will learn one page layout so what project i should consider because i have to apply to know how much i know i tried once and i made a nav bar with links and it was scrollable with paragraph and images though they weren't great looking on PC but mobile view it was fine so how to make it better and what should be next project


r/learnwebdev • • Oct 23 '19

Top 5 Udemy Courses To Become A Web Developer - Level Up Dev

Thumbnail
levelupdev.co
4 Upvotes

r/learnwebdev • • Oct 14 '19

Full stack books?

4 Upvotes

Hello there,

I'm currently learning web development and I decided to purchase one of those courses from Udemy (The Colt Steele one) the course is great but I just dont think the video format works for me when it comes to learning. Everything goes just so slow. (I just don't know how to put it honestly) I was wondering if there is any structured book out there similar to a course.

Thanks in advance!!


r/learnwebdev • • Oct 07 '19

The CSS Box Model – A Practical Guide

Thumbnail
levelupdev.co
4 Upvotes

r/learnwebdev • • Sep 14 '19

Best Buddies Nap - CSS drawing

Thumbnail
codecampanion.blogspot.com
4 Upvotes

r/learnwebdev • • Sep 03 '19

Preemptive tactics to improve your Lighthouse score

Thumbnail
medium.com
4 Upvotes

r/learnwebdev • • Aug 20 '19

Has anyone gone down the apprenticeship route? (UK)

4 Upvotes

When I was looking at what the local market is for web dev jobs I see a lot of listings for web dev apprenticeships, does any one know anything about the apprenticeship route?


r/learnwebdev • • Aug 07 '19

fetch api, include multiple files

4 Upvotes

stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file

im currently liking basic templating, and i consider it far easier than static sites. php and ssi includes are what im aiming for, but id like to explore other possiblities. how would one include multiple files using the newish fetch api? im currently using a jquery.load method and it works well. im using it to include a common header, navbar, and footer shared across the site.

<div class="load-html" data-source="path.files"></div>
$(function(){
 $(".load-html").each(function () {
  $(this).load(this.dataset.source);
 })
})

this fetch example works well, if only including 1 file, how do we include multiple files with a common class? what im trying to accomplish is bundling it like the above jquery.load.

fetch('path.files').then(function(response) {
 return response.text()
}).then(function(body) {
 document.body.innerHTML = body
})

near the bottom of the stackoverflow post, there is an example of multiple fetch files, but in the log i see only 1 fetched, and not displayed. changing the bottom root to doccument.body does display the only fetched file. when and where can the foreach be placed to work on all common class?

<div class="root" data-content="partial.html">
const root = document.querySelector('.root')
const link = root.dataset.content;
fetch(link).then(function (response) {
 return response.text();
}).then(function (html) {
 root.innerHTML = html
})

r/learnwebdev • • Jul 16 '19

Does anyone have a SoundCloud dev account?

4 Upvotes

So I wanted to start using the Soundcloud API for OAuth for a project but they're no longer accepting new app registrations. Does anyone have one that I could use?