{"id":23015656,"url":"https://github.com/rodrigo-dev7/chat-real-time","last_synced_at":"2026-04-05T21:01:41.910Z","repository":{"id":54900399,"uuid":"266130307","full_name":"Rodrigo-dev7/chat-real-time","owner":"Rodrigo-dev7","description":"Aplicação de chat real-timel conversando com um servidor em NodeJS.","archived":false,"fork":false,"pushed_at":"2022-12-12T20:56:24.000Z","size":57,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-08T20:46:42.666Z","etag":null,"topics":["chat","express","javascript","nodejs","real-time","socket-io"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rodrigo-dev7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-22T14:27:13.000Z","updated_at":"2020-05-22T16:38:19.000Z","dependencies_parsed_at":"2023-01-28T01:00:45.528Z","dependency_job_id":null,"html_url":"https://github.com/Rodrigo-dev7/chat-real-time","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Rodrigo-dev7/chat-real-time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rodrigo-dev7%2Fchat-real-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rodrigo-dev7%2Fchat-real-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rodrigo-dev7%2Fchat-real-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rodrigo-dev7%2Fchat-real-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rodrigo-dev7","download_url":"https://codeload.github.com/Rodrigo-dev7/chat-real-time/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rodrigo-dev7%2Fchat-real-time/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31449836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T15:22:31.103Z","status":"ssl_error","status_checked_at":"2026-04-05T15:22:00.205Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chat","express","javascript","nodejs","real-time","socket-io"],"created_at":"2024-12-15T11:12:49.189Z","updated_at":"2026-04-05T21:01:41.863Z","avatar_url":"https://github.com/Rodrigo-dev7.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CHAT REAL TIME\n\n![chat](https://user-images.githubusercontent.com/60434681/82680245-5eb59100-9c22-11ea-8951-42520e1e9c6f.gif)\n\n\n- Criar aplicações real-time com NodeJS fica muito fácil utilizando o poder do Socket.io.\nAplicação de chat em tempo real conversando com um servidor em NodeJS.\n\n## SOCKET  O que é \n- Socket.IO é uma biblioteca JavaScript para aplicativos da web em tempo real. Permite comunicação bidirecional em tempo real entre clientes e servidores da Web. Ele tem duas partes: uma biblioteca do lado do cliente que é executada no navegador e uma biblioteca do lado do servidor para o Node.js.\n\n## Server code\n```\nconst express = require('express');\nconst path = require('path');\n\nconst app = express();\nconst server = require('http').createServer(app);\nconst io = require('socket.io')(server);\n\napp.use(express.static(path.join(__dirname, 'public')));\napp.set('views', path.join(__dirname, 'public'));\napp.engine('html', require('ejs').renderFile);\napp.set('view engine', 'html');\n\n\napp.use('/', (req, res) =\u003e {\n  res.render('index.html')\n});\n\nlet messages = [];\n\nio.on('connection', socket =\u003e {\n  console.log(`Socket conectado: ${socket.id}`)\n\n  socket.emit('previousMessage', messages)\n\n  socket.on('sendMessage', data =\u003e {\n    messages.push(data);\n    socket.broadcast.emit('receivedMessage', data);\n  });\n})\n\nserver.listen(3000);\n```\n\n## Frontend Code\n```\n \u003cscript type=\"text/javascript\"\u003e\n    var socket = io('http://localhost:3000');\n\n    function renderMessage(message) {\n      $('.messages')\n      .append('\u003cdiv class=\"message\"\u003e\u003cstrong\u003e'+ message.author +'\u003c/strong\u003e: '+ message.message +'\u003c/div\u003e');\n    }\n\n    socket.on('previousMessage', function(messages) {\n      for (message of messages){\n        renderMessage(message)\n      }\n    })\n\n    socket.on('receivedMessage', function(message) {\n      renderMessage(message);\n    });\n\n    $('#chat').submit(function(event) {\n      event.preventDefault();\n\n      var author = $('input[name=username]').val();\n      var message = $('input[name=message]').val();\n\n      if (author.length \u0026\u0026 message.length) {\n        var messageObject = {\n          author: author,\n          message: message,\n        };\n\n        renderMessage(messageObject);\n\n        socket.emit('sendMessage', messageObject);\n      }\n    })\n  \u003c/script\u003e\n```\n\n## Dependencias\n```\n# yarn add els express socket.io \n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigo-dev7%2Fchat-real-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodrigo-dev7%2Fchat-real-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigo-dev7%2Fchat-real-time/lists"}