fix: make sure events are sorted

This commit is contained in:
evilsocket 2018-01-29 14:20:24 +01:00
commit 5d3381fc76
3 changed files with 14 additions and 2 deletions

View file

@ -3,6 +3,7 @@ package session
import (
"fmt"
"os"
"sort"
"sync"
"time"
@ -96,3 +97,14 @@ func (p *EventPool) Events() []Event {
defer p.Unlock()
return p.events
}
func (p *EventPool) Sorted() []Event {
p.Lock()
defer p.Unlock()
sort.Slice(p.events, func(i, j int) bool {
return p.events[i].Time.Before(p.events[j].Time)
})
return p.events
}