Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. import React from 'react';
  2. import {Link} from 'react-router';
  3. import {connect} from 'react-redux';
  4. import ws from './WebSocket';
  5. import {setUsername, socketConnectInit, socketOnOpen} from './actions/index';
  6. const PropTypes = React.PropTypes;
  7.  
  8.  
  9. class Landing extends React.Component {
  10. constructor(props, context) {
  11. super(props, context);
  12.  
  13. this.connectButton = this.connectButton.bind(this);
  14. }
  15.  
  16. connectButton() {
  17. const {dispatch} = this.props;
  18. let login = document.getElementById("usernameinput").value
  19. ws.sendmessage();
  20. console.log("Fired");
  21. //dispatch(setUsername(login));
  22. //dispatch(socketConnectInit(webSocket.url));
  23. //webSocket.onopen = () => {
  24. // console.log("websocket opened", webSocket);
  25. // webSocket.send(JSON.stringify({
  26. // type: "USER_CONNECTED",
  27. // username: login
  28. // }))
  29. // dispatch(socketOnOpen())
  30. // this.context.router.push({
  31. // pathname: '/Main'
  32. // })
  33. // dispatch(passWSS(webSocket));
  34. //};
  35. }
  36.  
  37. render() {
  38. return (
  39. <div className="container landing">
  40. <div className="row">
  41. <div className="col-sm-offset-4 col-md-offset-4 col-sm-4 col-md-4 text-center">
  42. <h2 className="signinHeader">SIGN IN</h2>
  43. <input className="form-control" type="text" id="usernameinput" placeholder="Username" />
  44. <button className="btn btn-success text-center" id="connectBtn" type="submit" onClick={this.connectButton}>Connect</button>
  45. </div>
  46. </div>
  47. </div>
  48. )
  49. }
  50.  
  51. }
  52.  
  53. Landing.contextTypes = {
  54. router: React.PropTypes.object.isRequired
  55. }
  56.  
  57. export default connect()(Landing);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement