- Collect synced packets to send within 1 second (cSendEmptyPacketTime) into buffer which is flushed each second.
- Send empty packet only if there was no other synced message within last second.
This should reduce traffic load: less bytes and less packets (less packets is very good for the server too).
{-# LANGUAGE OverloadedStrings, CPP #-}module HWProtoNEState whereimport Control.Monad.Readerimport qualified Data.ByteString.Char8 as B--------------------------------------import CoreTypesimport Actionsimport Utilsimport RoomsAndClientshandleCmd_NotEntered :: CmdHandlerhandleCmd_NotEntered ["NICK", newNick] = do (ci, irnc) <- ask let cl = irnc `client` ci if not . B.null $ nick cl then return [ProtocolError $ loc "Nickname already chosen"] else if illegalName newNick then return [ByeClient $ loc "Illegal nickname"] else return $ ModifyClient (\c -> c{nick = newNick}) : AnswerClients [sendChan cl] ["NICK", newNick] : [CheckRegistered | clientProto cl /= 0]handleCmd_NotEntered ["PROTO", protoNum] = do (ci, irnc) <- ask let cl = irnc `client` ci if clientProto cl > 0 then return [ProtocolError $ loc "Protocol already known"] else if parsedProto == 0 then return [ProtocolError $ loc "Bad number"] else return $ ModifyClient (\c -> c{clientProto = parsedProto}) : AnswerClients [sendChan cl] ["PROTO", showB parsedProto] : [CheckRegistered | not . B.null $ nick cl] where parsedProto = readInt_ protoNumhandleCmd_NotEntered ["PASSWORD", passwd] = do (ci, irnc) <- ask let cl = irnc `client` ci if passwd == webPassword cl then return $ JoinLobby : [AnswerClients [sendChan cl] ["ADMIN_ACCESS"] | isAdministrator cl] else return [ByeClient "Authentication failed"]#if defined(OFFICIAL_SERVER)handleCmd_NotEntered ["CHECKER", protoNum, newNick, password] = do (ci, irnc) <- ask let cl = irnc `client` ci if parsedProto == 0 then return [ProtocolError $ loc "Bad number"] else return $ [ ModifyClient (\c -> c{clientProto = parsedProto, nick = newNick, webPassword = password, isChecker = True}) , CheckRegistered] where parsedProto = readInt_ protoNum#endifhandleCmd_NotEntered _ = return [ProtocolError "Incorrect command (state: not entered)"]