def connect self.current_user = find_verified_user end protected def find_verified_user if current_user = User.find_by(id: cookies.signed[:user_id]) current_user else reject_unauthorized_connection end end end end
in Rails. // You can generate new channels where WebSocket features live using the rails generate channel command. // //= require action_cable //= require_self //= require_tree ./channels this.App = {}; App.cable = ActionCable.createConsumer();
Hello {this.props.name}, ({this.props.company}) Welcome to RubyNation </h1> ) } } let name = 'Yatish'; let company = 'Coupa'; ReactDOM.render(<HelloBox name={name} company={Coupa}/>, document.getElementById('container'));
Hello {this.props.name}, ({this.props.company}) Welcome to RubyNation </h1> ) } } let name = 'Yatish'; let company = 'Coupa'; ReactDOM.render(<HelloBox name={name} company={Coupa}/>, document.getElementById('container'));
{ received(data) { switch (data.action) { case "game_start": console.log('The game has started. You have been assigned a player.') this.setPlayer(data.player) this.updateMsg(data.msg) break; case "move": console.log("A move from opponent is received.") this.updateBoard(data.position, data.player) this.updateMsg(data.msg) break; } },