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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,14 @@ Welcome to your IRC project on Cloud9 IDE!

### You must host your code on github

#
Things to check if it isn't working.
Did we git add the file?
Did we git commit the file?
Did we git push?
Did you do a pull request?
Did I merge it on github?
Did I actually pull it?



22 changes: 22 additions & 0 deletions irc.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
DROP DATABASE IF EXISTS irc_db;
CREATE DATABASE irc_db;
\c irc_db;

CREATE TABLE IF NOT EXISTS users (
id serial,
username varchar(30),
password varchar(30),
PRIMARY KEY (id)
);

INSERT INTO users (id, username, password) VALUES
(DEFAULT, 'SpiderBall', 'sb'),
(DEFAULT, 'MidnaPeach', 'mp');

CREATE TABLE IF NOT EXISTS messages (
message_id serial,
original_poster_id int NOT NULL,
message_content bytea NULL,
PRIMARY KEY (message_id)
);

17 changes: 17 additions & 0 deletions postgreSQLCommands.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Command cheat sheet

change column name
ALTER TABLE [tablename] RENAME COLUMN [oldname] TO [newname];

copy table
CREATE TABLE [newtablename] AS SELECT [columns] FROM [existing];

change column data type
ALTER TABLE[tablename] ALTER COLUMN [columnname] TYPE [newtype];


insert
INSERT INTO [tablename] VALUES ([value1],[value2], ... );

update
UPDATE [tablename] SET [column1]=[value1] ... WHERE [somecolumn] = [somevalue];
11 changes: 8 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

def updateRoster():
names = []
for user_id in users:
for user_id in users:
print users[user_id]['username']
if len(users[user_id]['username'])==0:
names.append('Anonymous')
Expand All @@ -23,6 +23,7 @@ def updateRoster():
emit('roster', names, broadcast=True)



@socketio.on('connect', namespace='/chat')
def test_connect():
session['uuid']=uuid.uuid1()
Expand All @@ -32,17 +33,19 @@ def test_connect():
users[session['uuid']]={'username':'New User'}
updateRoster()


for message in messages:
emit('message', message)


@socketio.on('message', namespace='/chat')
def new_message(message):
#tmp = {'text':message, 'name':'testName'}
tmp = {'text':message, 'name':users[session['uuid']]['username']}
messages.append(tmp)
emit('message', tmp, broadcast=True)



@socketio.on('identify', namespace='/chat')
def on_identify(message):
print 'identify' + message
Expand All @@ -53,10 +56,12 @@ def on_identify(message):
@socketio.on('login', namespace='/chat')
def on_login(pw):
print 'login ' + pw
#we need to connect here.?


#users[session['uuid']]={'username':message}
#updateRoster()



@socketio.on('disconnect', namespace='/chat')
def on_disconnect():
Expand Down