-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
36 lines (28 loc) · 880 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var app = require("express")();
var http = require("http").Server(app);
var io = require("socket.io")(http);
app.get("/", function(req, res) {
res.sendFile(__dirname + "/index.html");
});
io.on("connection", function(socket) {
console.log("Client connected");
socket.on("disconnect", function() {
console.log("Client Left");
});
socket.on("availability", function(sfrequency,message) {
socket.to(sfrequency).emit("availability", message);
console.log(sfrequency,message)
});
socket.on("voicedata", function(ses,frequency) {
if (isNaN(frequency) || frequency < 1000000 || frequency > 9999999) {
console.log("Client try something new.")
} else {
socket.join(frequency);
socket.to(frequency).emit("voicedata", ses);
console.log("Sended to",frequency)
}
});
});
http.listen(80, function() {
console.log(":80 listening");
});