import { connect } from 'react-redux' ; import Redux from 'redux' ; import { MultiplayerEvent , StatusEvent } from 'shared/multiplayer/Events' ; import { handleEvent , registerHandler , rejectEvent , sendStatus , setMultiplayerConnected } from '../../actions/Multiplayer' ; import { ConnectionHandler } from '../../multiplayer/Connection' ; import { AppState , MultiplayerState } from '../../reducers/StateTypes' ; import MultiplayerClient , { DispatchProps , Props , StateProps } from './MultiplayerClient' ; const mapStateToProps = ( state , ownProps ) : StateProps => { return { multiplayer : state . multiplayer , commitID : state . commitID , } ; } ; const mapDispatchToProps = ( dispatch ) : DispatchProps => { return { onStatus : ( client ? , instance ? , status ? ) => { dispatch ( sendStatus ( client , instance , status ) ) ; } , onEvent : ( e , buffered , commitID , multiplayer ) => { dispatch ( handleEvent ( e , buffered , commitID , multiplayer ) ) ; } , onReject ( n , error ) { dispatch ( rejectEvent ( n , error ) ) ; } , onConnectionChange ( connected ) { dispatch ( setMultiplayerConnected ( connected ) ) ; } , onRegisterHandler ( handler ) { registerHandler ( handler ) ; } , } ; } ; const MultiplayerClientContainer = connect ( mapStateToProps , mapDispatchToProps ) ( MultiplayerClient ) ; export default MultiplayerClientContainer ;