Skip to content

A chat app that allows you to create groups, invite friends, and chat anonymously!

License

Notifications You must be signed in to change notification settings

DinamoTeam/Rapid-Chat

Repository files navigation

Rapid-Chat

A chat app that allows you to create groups, invite friends, and chat anonymously! Check it out here!

Development setup

This project uses .NET Core 2.1.1

Download SQLite3 https://sqlite.org/download.html

Install the EF Core SQL Server provider

dotnet add package Microsoft.EntityFrameworkCore.SqlServer

Create/Update the local instance of the DB

dotnet ef database drop
dotnet ef database update

This project was generated with Angular CLI version 8.3.9.

Install the CLI using NPM (Node.js >= 10 required)

npm install -g @angular/cli@8.3.9 

In the client's folder. Restore all NPM packages by running

npm install

This project uses peer to peer (PeerJS). Config PeerServer Replace the content in file Rapid-Chat\rapid-chat-client\node_modules\peer\node_modules\ws\index.js with the following

'use strict';

const WebSocket = require('./lib/websocket');

WebSocket.createWebSocketStream = require('./lib/stream');
WebSocket.Server = require('./lib/websocket-server');
WebSocket.Receiver = require('./lib/receiver');
WebSocket.Sender = require('./lib/sender');

module.exports = WebSocket;


const PeerServer = require('peer').PeerServer;
const server = PeerServer({
    port: 9000, 
    path: '/myapp'});

const baseUrl = 'https://localhost:44336/api/Room/';
const https = require('https');

server.on('connection', (client) => {/* Do nothing */});
server.on('disconnect', (client) => handleDisconnect(client));

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0; 

function handleDisconnect(client) {
    // Delete peer from Db
    const url = baseUrl + "DeletePeer?peerId=" + client.getId();
    https.get(url, response => {
        let data = '';
        response.on('data', chunk => {
            data += chunk;
        })
        response.on('end', () => {
            console.log(data);
            console.log('Deleted peer with id: ' + client.getId() + ' from database');
        })
    })
    .on('error', err => {
        console.log('Error: ' + err.message);
    });
}

Start PeerServer

node rapid-chat-client/node_modules/peer/node_modules/ws/index.js
### Go to this link to make sure PeerServer run successfully http://127.0.0.1:9000/myapp

Start IIS Express server through Visual Studio IDE or run this command in the project's folder

dotnet run

Run this command in the client's folder.

ng serve --open

Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.