{-| Module : EventLoop.Input.SystemMessage Description : Library of all the possible input 'SystemMessage' events in the example implementation. Copyright : (c) Sebastiaan la Fleur, 2014 License : BSD3 Maintainer : sebastiaan.la.fleur@gmail.com Stability : experimental Portability : All This module expresses how the incoming 'SystemMessage's are modelled in the example implementation. -} module EventLoop.Input.SystemMessage( SystemMessageIn(..) ) where import EventLoop.Json import EventLoop.Config {-| The different possible 'SystemMessageIn's. -} data SystemMessageIn = Setup -- ^ A request for the 'Setup'. This should be generated when the connection to a client is made. The answer should be a 'EventLoop.Output.CanvasSetup' message. | Background -- ^ A request for the 'Background'. This should be generated when the connection to a client is made. The answer could be the background of the graphical application. | Time -- ^ When a timer has been spawn, each \'tick\' a 'Time' is generated by the client to let the server know it is time. {-| Instance to express how to parse a 'SystemMessageIn' from a JSON formatted 'String'. -} instance FromJSON SystemMessageIn where fromJsonMessage (JSONObject ms) | message == setupS = Setup | message == backgroundS = Background | message == timeS = Time where JSONString message = retrieveError messageS ms