Skip to content

61040-fa22/recitation-final

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Chat App

Socket.IO

Install socket.io

npm install socket.io socket.io-client

Server

import { Server } from "socket.io";

...

// socket.io
const io = new Server(server, { // create websocket endpoint so that server & client can talk to each other
  cors: {
      origin: "*",
      methods: ['GET', "POST"]
  }
}); 

io.on("connection", (socket) => {
  console.log(`user ${socket.id} is connected.`);

  socket.on('disconnect', () => {
      console.log(`user ${socket.id} left.`);
  });
});

Client

import io from "socket.io-client";

...

created() {
    // initialize socket
    this.socketInstance = io("http://localhost:3000");
}

Deploying the app using Heroku

https://61040-fa22.github.io/pages/deployment.html

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published