-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated socket so endpoint is no longer needed and will use the curre…
…nt server and port by default. updated readme to reflect changes
- Loading branch information
1 parent
d7447fb
commit 3ff6efb
Showing
4 changed files
with
37 additions
and
65 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,41 @@ | ||
import React, { Component } from 'react'; | ||
|
||
import socketIOClient from 'socket.io-client'; | ||
|
||
let fbConfig = require('../../config/flightboard.config.js'); | ||
|
||
class Socket extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
response: false, | ||
now: new Date(), | ||
rooms: [], | ||
endpoint: fbConfig.socket.endpoint | ||
rooms: [] | ||
} | ||
} | ||
|
||
componentDidMount() { | ||
const { endpoint } = this.state; | ||
const socket = socketIOClient(endpoint); | ||
|
||
console.log("socket connect at: " + endpoint); | ||
console.log("====================================="); | ||
componentDidMount = () => { | ||
const socket = socketIOClient(); | ||
|
||
socket.on('updatedRooms', (rooms) => { | ||
let time = new Date(); | ||
for (var i = 0; i < rooms.length; i++) { | ||
var meetingRoom = rooms[i].Name; | ||
console.log("updating: " + meetingRoom); | ||
for (let i = 0; i < rooms.length; i++) { | ||
let meetingRoom = rooms[i].Name; | ||
} | ||
console.log(" "); | ||
console.log("time: " + time.toLocaleTimeString()); | ||
console.log("====================================="); | ||
|
||
this.props.response({ | ||
response: true, | ||
now: new Date(), | ||
rooms: rooms | ||
}) | ||
|
||
this.setState({ | ||
response: true, | ||
now: new Date(), | ||
rooms: rooms | ||
}); | ||
}); | ||
|
||
} | ||
|
||
componentWillUnmount () { | ||
const { endpoint } = this.state; | ||
const socket = socketIOClient(endpoint); | ||
componentWillUnmount = () => { | ||
const socket = socketIOClient(); | ||
socket.close(); | ||
} | ||
|
||
|
||
render() { | ||
return null; | ||
} | ||
|
||
} | ||
|
||
export default Socket; |
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