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 routes = ( | |
<Provider store={store}> | |
<Router history={hashHistory}> | |
<Route path="/" component={Landing}> | |
<IndexRoute component={Landing} /> | |
</Route> | |
<Route path="/main" component={Main} /> | |
</Router> | |
</Provider> | |
); |
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
export default const server = { | |
server: null, | |
getServer: return this.server, | |
create: () => { | |
const server = new WebSocket("ws://localhost:3000"); | |
this.server = server | |
}, | |
sendmessage: () => { | |
return server.onmessage = ()=> {} | |
} |
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 {Link} from 'react-router'; | |
import {connect} from 'react-redux'; | |
import ws from './WebSocket'; | |
import {setUsername, socketConnectInit, socketOnOpen} from './actions/index'; | |
const PropTypes = React.PropTypes; | |
class Landing extends React.Component { | |
constructor(props, context) { |
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
let promise = new Promise((resolve, reject) => { | |
let connected = ws.connect(); | |
resolve(connected); | |
}); | |
promise.then((data) = > { | |
console.log("Connected:", data) | |
}); |
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
let ws = new WebSocket("ws://localhost:3000"); | |
const server = { | |
connected: false, | |
connect: function() { | |
console.log("Connected", this.connected); | |
ws.onopen = () => { | |
console.log("CONNECTED!"); | |
} | |
ws.onerror = (e) => { |
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
connectButton() { | |
const {dispatch} = this.props; | |
let login = document.getElementById("usernameinput").value | |
//let promise = new Promise((resolve, reject) => { | |
// let connected = ws.connect(); | |
// resolve(connected); | |
//}); | |
//promise.then((data) => { | |
// console.log("Connected:", data); | |
// dispatch(socketOnOpen()); |
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, {PropTypes} from 'react'; | |
import {Link} from 'react-router'; | |
import {connect} from 'react-redux'; | |
import ws from './WebSocket'; | |
import {setUsername, socketConnectInit, socketOnOpen} from './actions/index'; | |
class Landing extends React.Component { | |
constructor(props, context) { | |
super(props, context); |
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
async connectButton() { | |
let connected = await this.wsConnect() | |
connected ? console.log("CONNECTED", connected) : console.log("NOT CONNECTED", connected); | |
} | |
async wsConnect() { | |
return await ws.connect(); | |
} |
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, {PropTypes} from 'react'; | |
import {Link} from 'react-router'; | |
import {connect} from 'react-redux'; | |
import ws from './WebSocket'; | |
import {setUsername, socketConnectInit, socketOnOpen} from './actions/index'; | |
class Landing extends React.Component { | |
constructor(props, context) { | |
super(props, context); |
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 express from "express"; | |
import url from 'url'; | |
import path from 'path'; | |
const WebSocketServer = require('ws').Server; | |
const http = require('http').Server(app); | |
const wss = new WebSocketServer({ | |
server: http | |
}); | |
const app = express(); | |
app.use(express.static(path.resolve('../'))); |