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
import React from 'react'; | |
import logo from './logo.svg'; | |
import withSocket from "./withSocket" | |
import './App.css'; | |
function App({socketListen, socketSend}) { | |
socketListen("loginResponse", (response) => { | |
console.log(response) | |
}) |
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
const express = require("express") | |
const socketIO = require('socket.io'); | |
const http = require('http') | |
var rabbit = require('amqplib/callback_api'); | |
const pino = require('pino'); | |
require('dotenv').config(); | |
const LOGGER = pino({ level: process.env.LOG_LEVEL || 'info' }); | |
const queues = ["userLogin", "frontendMessage"] |
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
var rabbit = require('amqplib/callback_api'); | |
const pino = require('pino'); | |
require('dotenv').config(); | |
const LOGGER = pino({ level: process.env.LOG_LEVEL || 'info' }); | |
const queues = ["userLogin", "frontendMessage"] | |
LOGGER.info(`Connecting to RabbitMQ`) |
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
io.on('connection', (socket)=>{ | |
LOGGER.debug(`New user connected ${socket.id}`) | |
socket.on("message", (data) => { | |
let event = JSON.parse(data) | |
LOGGER.debug(event) | |
event.socketId = socket.id | |
rabbit.channel.send("userLogin", event) | |
}) | |
}); |
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
const express = require("express") | |
const socketIO = require('socket.io'); | |
const http = require('http') | |
var rabbit = require('amqplib/callback_api'); | |
const pino = require('pino'); | |
require('dotenv').config(); | |
const LOGGER = pino({ level: process.env.LOG_LEVEL || 'info' }); |
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
var rabbit = require('amqplib/callback_api'); | |
const pino = require('pino'); | |
require('dotenv').config(); | |
const LOGGER = pino({ level: process.env.LOG_LEVEL || 'info' }); | |
LOGGER.info(`Connecting to RabbitMQ`) | |
rabbit.connect('amqp://localhost', (error0, connection) => { | |
if (error0) { | |
throw error0; |
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
import React from 'react'; | |
import logo from './logo.svg'; | |
import withSocket from "./withSocket" | |
import './App.css'; | |
function App({socketListen, socketSend}) { | |
socketSend("message", {name: "i am connected"}) | |
return ( |
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
import React from "react" | |
import socketIOClient from "socket.io-client"; | |
// link should be in environemnt file! | |
let socket = socketIOClient(process.env.REACT_APP_SOCKET_URL) | |
// component wrapper that allows us to use socket globaly | |
function withSocket (WrappedComponent) { | |
const WithSocket = props => { |
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
const express = require("express") | |
const socketIO = require('socket.io'); | |
const http = require('http') | |
const pino = require('pino'); | |
require('dotenv').config(); | |
const LOGGER = pino({ level: process.env.LOG_LEVEL || 'info' }); | |
LOGGER.info("Starting server") |
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
{ | |
"name": "msrouter", | |
"version": "1.0.0", | |
"description": "", | |
"main": "msRouter.js", | |
"scripts": { | |
"start": "nodemon --exec babel-node msRouter.js", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", |
NewerOlder