0% found this document useful (0 votes)
12 views3 pages

Socket.IO Chat Application Code

Uploaded by

nareshvarre4
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Socket.IO Chat Application Code

Uploaded by

nareshvarre4
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//////////////////////index.

html/////////////////////

<!DOCTYPE html>
<html>

<head>
<title>[Link] chat</title>
<style>
body {
margin: 0;
padding-bottom: 3rem;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Helvetica, Arial, sans-serif;
}

#form {
background: rgba(0, 0, 0, 0.15);
padding: 0.25rem;
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
height: 3rem;
box-sizing: border-box;
backdrop-filter: blur(10px);
}

#input {
border: none;
padding: 0 1rem;
flex-grow: 1;
border-radius: 2rem;
margin: 0.25rem;
}

#input:focus {
outline: none;
}

#form>button {
background: #333;
border: none;
padding: 0 1rem;
margin: 0.25rem;
border-radius: 3px;
outline: none;
color: #fff;
}

#messages {
list-style-type: none;
margin: 0;
padding: 0;
}

#messages>li {
padding: 0.5rem 1rem;
}
#messages>li:nth-child(odd) {
background: #efefef;
}
</style>
</head>

<body>
<ul id="messages"></ul>
<form id="form" action="">
<input id="input" autocomplete="off" /><button>Send</button>
</form>
<script src="/[Link]/[Link]"></script>
<script>
var socket = io();

var messages = [Link]('messages');


var form = [Link]('form');
var input = [Link]('input');

[Link]('submit', function (e) {


[Link]();
if ([Link]) {
[Link]('chat message', [Link]);
[Link] = '';
}
});

[Link]('chat message', function (msg) {


var item = [Link]('li');
[Link] = msg;
[Link](item);
[Link](0, [Link]);
});
</script>
</body>

</html>

/////////////////////////////////////[Link]/////////////////////////////////////

let server = [Link](3004, function(){


// [Link]([Link] + ';__dirname:' + __dirname + ';');
[Link]('Unione API Server started @Port : ' + [Link]().port);
// [Link]('server started @Port : ' + [Link]().port + ', Time :
'+new Date());
});
const io = require('[Link]')(server,{
pingTimeout:60000,
cors:{
origin:'*'

}
});
[Link]('connection', (socket) => {
[Link]('chat message', (msg) => {
[Link]('chat message', msg);
});
});

//////////////////////[Link]///////////////////////
function getList(query, callback) {
// [Link]('Associate :: getList()');
//[Link] = "Active";
[Link](query, function (error, associateRecords) {
if (error) {
callback({
status: DB_CODES.FAIL,
error: error
});
return;
} else {
associateRecords = [Link](function
(associateRecord) {
var associateRecord = new
[Link](associateRecord);
return associateRecord;
});
// [Link]('Associate :: getList() :: callback');
callback({
status: REQUEST_CODES.SUCCESS,
result: associateRecords
});
return;
}
}).sort({ 'associateId': 1 });
}

You might also like