anchor.diff:          appServer.dbFnArgs       <- defaultArg (toOption "dbFnArgs")   appServer.dbFnArgs
           appServer.dbFnResult     <- defaultArg (toOption "dbFnResult") appServer.dbFnResult
           appServer.antiFloodRules <- config.GetChildConfig<AntiFloodConfigCollection> "antiflood" |> Seq.cast |> toList
  -
           true
       
       override appServer.OnStartup() =
  -
  -        let isInBlackList (s:IAppSession) = exists ((=) (s.RemoteEndPoint.Address.ToString())) appServer.BlackList
  -        let ipAddress     (s:IAppSession) = s.RemoteEndPoint.Address.ToString()
  -
           setLogFileName "Server-log"
           let setScreenLogLevel level =
               appServer.MinScreenLogLevel <- level
  
positive.code:             return! (loop())}
          loop())
      do agent.Error.Add (log Fatal "Terminate execution due to unhandled exception in the AntiFloodMailboxProcessor. Exception was: %A")
      member this.post time buffers msg cont stop = agent.Post (time, buffers, msg, cont, stop)
  
  [<AllowNullLiteral>]
  type CustomProtocolSession() =
      inherit AppSession<CustomProtocolSession, BinaryRequestInfo>()
      let messageLogSize = 100
      let lastMessages   = Array.zeroCreate messageLogSize
      member val AntiFloodState  = new AntiFlood() with get
      member val AntiFloodRules  = []             with get, set
      member val Authenticated   = false          with get, set
      member val ProtocolVersion = (0, 0)         with get, set
      member val ClientVersion   = (0, 0)         with get, set
      member val MessageHash     = (-1, null)     with get, set
      member this.CheckMessageOrder msgId =
          let  v = lastMessages.[msgId % messageLogSize]
          if   v = msgId then log Warn "Duplicate message: %i - Session: %s" msgId this.SessionID ; false
          elif v > msgId then log Warn "New messageId: %i is too old compared with previous one: %i - Session: %s" msgId v this.SessionID; false
          else lastMessages.[msgId % messageLogSize] <- msgId; true
      override this.HandleException(e) =
          log Fatal "Unhandled exception in session: %s : %A " this.SessionID e
          this.Close(CloseReason.ApplicationError)
  
  type MyReceiveFilter (appServer,  appSession:CustomProtocolSession, remoteEndPoint) =
      inherit FixedHeaderReceiveFilter<BinaryRequestInfo> 6
      override this.GetBodyLengthFromHeader(header, offset, length) =
          if not (header.[offset] = 114uy) || not (header.[offset + 1] = 0uy) then
              log Warn "Invalid headers: %i - %i received from %A , session: %s . Client is %sauthenticated, will disconnect." header.[offset] header.[offset+1] remoteEndPoint appSession.SessionID (if appSession.Authenticated then "" else "not ")
              appSession.Close(CloseReason.ProtocolError)
              0
          else fromBytesWithOptions false (offset+2) header
      override this.ResolveRequestInfo(header, bodyBuffer, offset, length) = 
  
negative.code:                 if not s.Authenticated && (DateTime.Now - s.StartTime).TotalSeconds > 60. then 
                      log Debug "Session %s from %s Timeout." s.SessionID (ipAddress s)
                      s.Close CloseReason.TimeOut)
  
          appServer.add_NewRequestReceived  (RequestHandler<_, _> evtRequest)
          appServer.add_NewSessionConnected (SessionHandler<_>    evtLogin  )
          appServer.add_SessionClosed       (SessionHandler<_, _> evtLogout )
          let timer = new Timers.Timer 15000.
          timer.Elapsed.Add evtStatus
          timer.Enabled <- true
                  
          base.OnStarted()