gameServer/CoreTypes.hs
changeset 4918 c6d3aec73f93
parent 4907 8bf14795a528
child 4932 f11d80bac7ed
equal deleted inserted replaced
4917:8ff92bdc9f98 4918:c6d3aec73f93
    11 import Data.Sequence(Seq, empty)
    11 import Data.Sequence(Seq, empty)
    12 import Data.Time
    12 import Data.Time
    13 import Network
    13 import Network
    14 import Data.Function
    14 import Data.Function
    15 import Data.ByteString.Char8 as B
    15 import Data.ByteString.Char8 as B
       
    16 import Data.Unique
    16 
    17 
    17 import RoomsAndClients
    18 import RoomsAndClients
    18 
    19 
    19 type ClientChan = Chan [B.ByteString]
    20 type ClientChan = Chan [B.ByteString]
    20 
    21 
    21 data ClientInfo =
    22 data ClientInfo =
    22     ClientInfo
    23     ClientInfo
    23     {
    24     {
       
    25         clUID :: Unique,
    24         sendChan :: ClientChan,
    26         sendChan :: ClientChan,
    25         clientSocket :: Socket,
    27         clientSocket :: Socket,
    26         host :: B.ByteString,
    28         host :: B.ByteString,
    27         connectTime :: UTCTime,
    29         connectTime :: UTCTime,
    28         nick :: B.ByteString,
    30         nick :: B.ByteString,
   159     | Guest
   161     | Guest
   160     | Admin
   162     | Admin
   161     deriving (Show, Read)
   163     deriving (Show, Read)
   162 
   164 
   163 data DBQuery =
   165 data DBQuery =
   164     CheckAccount ClientIndex B.ByteString B.ByteString
   166     CheckAccount ClientIndex Int B.ByteString B.ByteString
   165     | ClearCache
   167     | ClearCache
   166     | SendStats Int Int
   168     | SendStats Int Int
   167     deriving (Show, Read)
   169     deriving (Show, Read)
   168 
   170 
   169 data CoreMessage =
   171 data CoreMessage =
   170     Accept ClientInfo
   172     Accept ClientInfo
   171     | ClientMessage (ClientIndex, [B.ByteString])
   173     | ClientMessage (ClientIndex, [B.ByteString])
   172     | ClientAccountInfo (ClientIndex, AccountInfo)
   174     | ClientAccountInfo ClientIndex Int AccountInfo
   173     | TimerAction Int
   175     | TimerAction Int
   174     | Remove ClientIndex
   176     | Remove ClientIndex
   175 
   177 
   176 instance Show CoreMessage where
   178 instance Show CoreMessage where
   177     show (Accept _) = "Accept"
   179     show (Accept _) = "Accept"
   178     show (ClientMessage _) = "ClientMessage"
   180     show (ClientMessage _) = "ClientMessage"
   179     show (ClientAccountInfo _) = "ClientAccountInfo"
   181     show (ClientAccountInfo {}) = "ClientAccountInfo"
   180     show (TimerAction _) = "TimerAction"
   182     show (TimerAction _) = "TimerAction"
   181     show (Remove _) = "Remove"
   183     show (Remove _) = "Remove"
   182 
   184 
   183 type MRnC = MRoomsAndClients RoomInfo ClientInfo
   185 type MRnC = MRoomsAndClients RoomInfo ClientInfo
   184 type IRnC = IRoomsAndClients RoomInfo ClientInfo
   186 type IRnC = IRoomsAndClients RoomInfo ClientInfo