Last active
May 3, 2016 22:30
-
-
Save sethdorris/f38e64986b2ca6bef5beebcffebee3b8 to your computer and use it in GitHub Desktop.
exporting
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) { | |
super(props, context); | |
this.connectButton = this.connectButton.bind(this); | |
} | |
connectButton() { | |
const {dispatch} = this.props; | |
let login = document.getElementById("usernameinput").value | |
ws.sendmessage(); | |
console.log("Fired"); | |
//dispatch(setUsername(login)); | |
//dispatch(socketConnectInit(webSocket.url)); | |
//webSocket.onopen = () => { | |
// console.log("websocket opened", webSocket); | |
// webSocket.send(JSON.stringify({ | |
// type: "USER_CONNECTED", | |
// username: login | |
// })) | |
// dispatch(socketOnOpen()) | |
// this.context.router.push({ | |
// pathname: '/Main' | |
// }) | |
// dispatch(passWSS(webSocket)); | |
//}; | |
} | |
render() { | |
return ( | |
<div className="container landing"> | |
<div className="row"> | |
<div className="col-sm-offset-4 col-md-offset-4 col-sm-4 col-md-4 text-center"> | |
<h2 className="signinHeader">SIGN IN</h2> | |
<input className="form-control" type="text" id="usernameinput" placeholder="Username" /> | |
<button className="btn btn-success text-center" id="connectBtn" type="submit" onClick={this.connectButton}>Connect</button> | |
</div> | |
</div> | |
</div> | |
) | |
} | |
} | |
Landing.contextTypes = { | |
router: React.PropTypes.object.isRequired | |
} | |
export default connect()(Landing); |
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 ws = new WebSocket("ws://localhost:3000"); | |
const server = { | |
sendmessage: () => { | |
ws.send = () => { | |
JSON.stringify({message: "Hi"}); | |
} | |
}, | |
getserver: () => { | |
return ws; | |
} | |
} | |
export default server; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment