mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-21 09:08:57 +00:00
Merge branch 'master' into update-test
This commit is contained in:
commit
bd4f9868ec
5 changed files with 15 additions and 16 deletions
|
|
@ -24,7 +24,7 @@ type Director struct {
|
|||
const FPS = 60
|
||||
|
||||
func NewDirector(roomID string, imageChannel chan *image.RGBA, audioChannel chan float32, inputChannel chan int) *Director {
|
||||
// return image channel from where it write
|
||||
// TODO: return image channel from where it write
|
||||
director := Director{}
|
||||
director.Done = make(chan struct{})
|
||||
director.audioChannel = audioChannel
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ func (console *Console) Step() int {
|
|||
console.PPU.Step()
|
||||
console.Mapper.Step()
|
||||
}
|
||||
//for i := 0; i < cpuCycles; i++ {
|
||||
//console.APU.Step()
|
||||
//}
|
||||
for i := 0; i < cpuCycles; i++ {
|
||||
console.APU.Step()
|
||||
}
|
||||
return cpuCycles
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ func (h *Handler) WS(w http.ResponseWriter, r *http.Request) {
|
|||
wssession.BrowserClient.Listen()
|
||||
|
||||
// TODO: Use callback
|
||||
// listen to socket done to close peerconnection
|
||||
// If peerconnection is done (client.Done is signalled), we close peerconnection
|
||||
go func() {
|
||||
for {
|
||||
<-client.Done
|
||||
|
|
|
|||
|
|
@ -75,9 +75,8 @@ func (s *Session) RouteOverlord() {
|
|||
"start",
|
||||
func(resp cws.WSPacket) (req cws.WSPacket) {
|
||||
log.Println("Received a start request from overlord")
|
||||
log.Println("Add the connection to current room on the host")
|
||||
log.Println("Add the connection to current room on the host ", resp.SessionID)
|
||||
|
||||
log.Println("SessionID : ", resp.SessionID)
|
||||
peerconnection := oclient.peerconnections[resp.SessionID]
|
||||
log.Println("start session")
|
||||
|
||||
|
|
|
|||
|
|
@ -148,9 +148,8 @@ func (r *Room) CleanSession(peerconnection *webrtc.WebRTC) {
|
|||
|
||||
func (r *Room) removeSession(w *webrtc.WebRTC) {
|
||||
fmt.Println("Cleaning session: ", w)
|
||||
//r.sessionsLock.Lock()
|
||||
//defer r.sessionsLock.Unlock()
|
||||
fmt.Println("Sessions list", r.rtcSessions)
|
||||
// TODO: get list of r.rtcSessions in lock
|
||||
for i, s := range r.rtcSessions {
|
||||
fmt.Println("found session: ", s, w)
|
||||
if s.ID == w.ID {
|
||||
|
|
@ -171,14 +170,15 @@ func (r *Room) removeSession(w *webrtc.WebRTC) {
|
|||
}
|
||||
|
||||
func (r *Room) Close() {
|
||||
if r.Done == false {
|
||||
log.Println("Closing room", r.ID)
|
||||
log.Println("Closing director of room ", r.ID)
|
||||
close(r.director.Done)
|
||||
log.Println("Closing input of room ", r.ID)
|
||||
close(r.inputChannel)
|
||||
r.Done = true
|
||||
if r.Done {
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("Closing room", r.ID)
|
||||
log.Println("Closing director of room ", r.ID)
|
||||
close(r.director.Done)
|
||||
log.Println("Closing input of room ", r.ID)
|
||||
close(r.inputChannel)
|
||||
r.Done = true
|
||||
// Close here is a bit wrong because this read channel
|
||||
//close(r.imageChannel)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue