Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions lab-david/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/node_modules/*
**/vendor/*
**/*.min.js
**/coverage/*
**/build/*
31 changes: 31 additions & 0 deletions lab-david/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"env": {
"browser": true,
"node": true,
"commonjs": true,
"jest": true,
"es6": true
},
"globals": {
"err": true,
"req": true,
"res": true,
"next": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"rules": {
"no-console": "off",
"indent": [ "error", 2, { "SwitchCase": 1 } ],
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"space-infix-ops": ["error", {"int32Hint": false}],
"comma-dangle": ["error", "always-multiline"],
"semi": [ "error", "always" ]
}
}
155 changes: 155 additions & 0 deletions lab-david/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# db directory
db


# temp directory
temp

# Created by https://www.gitignore.io/api/osx,vim,node,linux,windows,visualstudiocode

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env


### OSX ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Vim ###
# swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# session
Session.vim
# temporary
.netrwhist
# auto-generated tag files
tags

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/osx,vim,node,linux,windows,visualstudiocode
11 changes: 11 additions & 0 deletions lab-david/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Code Fellows
## Project for Sockets

This is a project for sockets.


### How to use?

`npm install`
open this [link](http://localhost:3000) in your browser
Chat to your heart's content
38 changes: 38 additions & 0 deletions lab-david/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';

let express = require('express');
let app = express();
let http = require('http').Server(app);
let io = require('socket.io')(http);
let moment = require('moment');

app.use(express.static('./public'));

const USERS = {};

io.on('connection', (socket) => {
USERS[socket.id] = {};
USERS[socket.id].username = 'USER';

socket.on('disconnect', () => {
console.log('DISCONNECTED', socket.id);
});

socket.on('send-message', (data) => {
data.username = USERS[socket.id].username;
data.timeStamp = moment().format('MMMM Do YYYY, h:mm:ss a');

console.log('MESSAGE:', data.message);
io.emit('receive-message', data);
});

socket.on('set-username', (data) => {
USERS[socket.id].username = data.username;

});
});

let port = 3000;
http.listen(port, () => {
console.log('http://localhost:' + port);
});
1 change: 1 addition & 0 deletions lab-david/node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading