Coder Social home page Coder Social logo

awesomeplays3 / discode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mansoo-kim/discode

0.0 0.0 0.0 6.12 MB

Discode is a clone of Discord. Users can create and join servers, add friends, customize icons/avatars, and live chat in various chatrooms such as channels, direct messages, and group chats.

Ruby 24.11% JavaScript 53.55% SCSS 19.77% HTML 2.57%

discode's Introduction

Discode

Discode is a Discord clone, an instant messaging platform. On Discode, users can create and join servers, add friends, and chat in various chatrooms such as channels, direct messages, and group chats.

Technologies Used

  • Frontend: React, Redux, SCSS
  • Backend: Ruby on Rails, PostgreSQL
  • Live Chat: Action Cable WebSockets
  • Storage: Amazon S3

Key Features

Live Chat

  • Users can live chat in channels inside servers, private direct messages, and group chats.

  def subscribed
    if (params[:type] == "Channel")
      @chat = Channel.find_by(id: params[:id])
    else
      @chat = Conversation.find_by(id: params[:id])
    end

    stream_for @chat
  end

  def receive(data)
    @message = Message.new(data)
    if @message.save
      res = {
        message: message_json,
        type: "message"
      }
      ChatChannel.broadcast_to(@chat, res)
    end
  end
  useEffect(() => {
    const chat = App.cable.subscriptions.create(
      { channel: "ChatChannel", type: type, id: cc.id },
      {
        received: (res) => {
          switch (res.type) {
            case 'message':
              receiveMessage(res.message);
              break;
            case 'remove':
              removeMessage(res.message);
              break;
          }
        },
        update: function(data) {
          return this.perform("update", data);
        },
        delete: function(data) {
          return this.perform("delete", data);
        }
      }
    )
    setChat(chat);
    return () => chat.unsubscribe();
  }, [type, cc.id]);

Servers and Channels

  • Users can create/edit/delete their own servers and channels, or join other servers.
  • Servers can have a custom server icon.

Friends and Direct Messsages/Group Chats

  • Users can add/remove friends.
  • Users can use the Friends tab to start new direct messages or group chats, and accept/ignore pending requests.

  const findIfSelected = (toAdd) => selectedFriends.findIndex(friend => friend.id === toAdd.id);

  const toggleFriend = (friend) => {
    const idx = findIfSelected(friend);
    if (idx > -1) {
      setSelectedFriends(prevState => {
        const newState = [...prevState]
        newState.splice(idx, 1);
        return newState;
      });
    } else {
      setSelectedFriends(prevState => [...prevState, friend]);
      setSearchText("");
    }
  }

discode's People

Contributors

mansoo-kim 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.