Giter Club home page Giter Club logo

rtw's Introduction

Real time Spotify app

Spotichat

With this app you can search a song from your favorite artist. After finding the song you were looking for, you can click on the song and it will send you to a chatroom. Here you can live chat with other users about the song.

demo

Wishlist

  • Combine birthdates of artist/icons to the currentdate on the homepage and link that to a chat
  • Create a sticy scroll for the chat
  • Show how many users are online

Index

I used the spotify api to gain access to all the songs and artists.

I used express-session to create an access token that only last a session. This way every user can access multiple chats with the same ID and nickname.

    if(req.session.userID === undefined){
        // generate id for new user
        var userID = shortid.generate();

        // save id to session
        req.session.userID = userID;

        // save id to users "database"
        users[userID] = {
            name: 'Ano niem'
        }
    }

I used Socket.io for the real time connection for sending messages.

// Receive a message from the message form
    socket.on('message', function(messageData) { // [2]
        var trackID = messageData.trackID;
        var message = messageData.message;
        var userID = messageData.userID;
        var username = users[userID].name;

        var message = {
            userID: userID,
            message: message,
            date: new Date()
        };

        // Update "database"
        chatrooms[trackID].messages.push(message);

        // Add the username to the message before we send it to the other clients
        message.username = username;

        // Send message to all clients without sender
        socket.broadcast.emit('message', message); // [3]
    });

First clone the repo:

git clone https://github.com/GiuliaM/rtw.git

After that:

npm install

Now start up the server:

npm start

rtw's People

Contributors

giuliam avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.