scorebored / scorebored-2-alpha

Scorebored, Version 2
MIT License
1 stars 0 forks source link

Implement match history format #8

Closed mike-mcgann closed 11 years ago

mike-mcgann commented 11 years ago

History of the game match shall be rendered as follows (but don't forget the timestamps, those are relative from the start of the match):

history = [
    {
        games: [0, 0],
        scoring: [
            { score: [1, 0], award: 0, server: 0 }
            { score: [1, 1], award: 1, server: 0 },
            { score: [2, 1], award: 0, server: 1 },
            { score: [3, 1], award: 0, server: 1 },
            { score: [4, 1], award: 0, server: 0 },
            { score: [5, 1], award: 0, server: 0 },
            { score: [6, 1], award: 0, server: 1 },
            { score: [7, 1], award: 0, server: 1 },
            { score: [8, 1], award: 0, server: 0 },
            { score: [9, 1], award: 0, server: 0 },
            { score: [10, 1], award: 0, server: 1 },
            { score: [11, 1], award: 0, server: 1 },
        ]
    },
    {
        games: [1, 0],
        scoring: [
            { score: [1, 0], award: 0, server: 0 }
            { score: [1, 1], award: 1, server: 0 },
            { score: [2, 1], award: 0, server: 1 },
            { score: [3, 1], award: 0, server: 1 },
            { score: [4, 1], award: 0, server: 0 },
            { score: [5, 1], award: 0, server: 0 },
            { score: [6, 1], award: 0, server: 1 },
            { score: [7, 1], award: 0, server: 1 },
            { score: [8, 1], award: 0, server: 0 },
            { score: [9, 1], award: 0, server: 0 },
            { score: [10, 1], award: 0, server: 1 },
            { score: [11, 1], award: 0, server: 1 },
        ]
    }    
]
chugcup commented 11 years ago

What is the best way to update the server and other browsers when new points are awarded? Do we send individual "update" messages with just the latest point(s) each (and have them tacked on the end of the match state)? What happens when the user mashes on the +1 point button repeatedly? Should we throttle messages so they are only sent once every 5 seconds or so? Maybe we should periodically sync the match state with the server?

mike-mcgann commented 11 years ago

I think the easiest would to run the engine on the server. In games where you don't have a server, the engine would run in the browser. When the "+ Point" button is hit, that gets sent to the engine/server, it notifies all clients of the event (including the controlling client that sent the "+ Point" request) and they update their displays. This would ensure that everyone is consistent and displays don't update until recognized by the server.

The connection from the controlling device to the server would have to be good or lag would be seen when pressing buttons. I think that is okay. Benefits are that any client could potentially be a controller (remote control, handoffs). Also, when a client joins late, he will need to request what the current state is. Much easier if all that is all on in the server.

I think throttling is easy enough to put in later if needed. Starting out I think we should try direct updates and see how it goes as that would provide the best experience.

Thoughts?

chugcup commented 11 years ago

For the most part the connections will be good, and if we are using web sockets there will be little overhead for small point update messages. We'll have to do some testing to see how it performs; if we see issues on mobile, we might want to just immediately update the UI. The last thing you want is a button that doesn't give you feedback within a half second

mike-mcgann commented 11 years ago

How about if we go the other way around? Instead of the displays being "dumb" and told what to do, they are "smart". There is a game engine in the master browser, one on the server, and each client has one too. When "+ Point" is pressed on the master browser, that engine is updated and the "+ Point" command goes to the server. It runs that through its own engine, and then broadcasts out the "+ Point" command and each client runs it through their engines. That way the master browser can update its state immediately. Server has a copy of the state for the clients who join late.

chugcup commented 11 years ago

I concur.

mike-mcgann commented 11 years ago

Latest information on this is on the Pong Engine wiki page.