-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
2,043 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>OutRed Chatbox</title> | ||
<meta name = "charset" charset = "utf-8"> | ||
<meta name = "viewport" content = "width=device-width"> | ||
<link rel = "stylesheet" type = "text/css" href = "style.css"> | ||
<script src = "script.js"></script> | ||
<script src= "socket.io/socket.io.js"></script> | ||
</head> | ||
<body onload = "onload()"> | ||
<div id = "Main"> | ||
<audio id = "Ding" src = "Ding.mp3"> </audio> | ||
<center><h1 id = "Title"> OutRed Chatbox</h1></center> | ||
<center><p>Talk to anybody by connecting or creating a chatroom!</p></center> | ||
<div id = "AccessPort"> | ||
<label id = "NameLabel"> </label> | ||
<input id = "NameInput" placeholder="Enter Username" type = "text"> | ||
<br><br> | ||
<label id = "IDLabel"> </label> | ||
<input id = "IDInput" value = "" placeholder="Join/Create Chatroom" type = "text"> | ||
<input id = "ConnectButton" class = "Button" type = "submit" value = "Connect" onclick = "Connect()"> | ||
</div> | ||
<h2 id = "RoomID"> Chatroom : None </h2> | ||
<div id = "Chat"> | ||
<p id = "Message0" class = "Message"> - </p> | ||
<p id = "Message1" class = "Message"> - </p> | ||
<p id = "Message2" class = "Message"> - </p> | ||
<p id = "Message3" class = "Message"> - </p> | ||
<p id = "Message4" class = "Message"> - </p> | ||
<p id = "Message5" class = "Message"> - </p> | ||
<p id = "Message6" class = "Message"> - </p> | ||
<p id = "Message7" class = "Message"> - </p> | ||
<p id = "Message8" class = "Message"> - </p> | ||
<p id = "Message9" class = "Message"> - </p> | ||
<label id = "MessageLabel"> </label> | ||
<input id = "ComposedMessage" placeholder="Your Message"type = "text"> | ||
<input id = "SendMessage" onclick="Send()" value = "Send" class = "Button" type = "submit"> | ||
</div> | ||
<br><br> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const http = require("http"); | ||
const express = require("express"); | ||
const socketio = require("socket.io"); | ||
const path = require("path"); | ||
|
||
const app = express(); | ||
const httpserver = http.Server(app); | ||
const io = socketio(httpserver); | ||
|
||
const gamedirectory = path.join(__dirname, "html"); | ||
|
||
app.use(express.static(gamedirectory)); | ||
|
||
httpserver.listen(3000); | ||
|
||
var rooms = []; | ||
var usernames = []; | ||
|
||
io.on('connection', function(socket){ | ||
|
||
socket.on("join", function(room, username){ | ||
if (username != ""){ | ||
rooms[socket.id] = room; | ||
usernames[socket.id] = username; | ||
socket.leaveAll(); | ||
socket.join(room); | ||
io.in(room).emit("recieve", "Server: " + username + " has joined a chatroom."); | ||
socket.emit("join", room); | ||
} | ||
}) | ||
|
||
socket.on("send", function(message){ | ||
io.in(rooms[socket.id]).emit("recieve", usernames[socket.id] +" : " + message); | ||
}) | ||
|
||
socket.on("recieve", function(message){ | ||
socket.emit("recieve", message); | ||
}) | ||
}) |
Oops, something went wrong.