small changes
This commit is contained in:
parent
77b1a93b30
commit
d3b3a62f28
5 changed files with 27 additions and 19 deletions
8
event.go
8
event.go
|
|
@ -27,7 +27,9 @@ func (ev DialEvent) HandleOutgoing(app *App) error {
|
|||
var err error
|
||||
|
||||
if app.conn != nil {
|
||||
app.incoming <- SystemMessageEvent(fmt.Sprintf("already connected to %s:%s", app.conn.host, app.conn.port))
|
||||
app.incoming <- SystemMessageEvent(
|
||||
fmt.Sprintf("already connected to %s:%s", app.conn.host, app.conn.port),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
conn, err := net.Dial("tcp", net.JoinHostPort(ev.Host, ev.Port))
|
||||
|
|
@ -51,8 +53,8 @@ func (ev DialEvent) HandleOutgoing(app *App) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
delta := time.Since(latStart).Round(time.Second)
|
||||
delta = min(max(time.Second, delta*3/2), 5*time.Second)
|
||||
delta := time.Since(latStart)
|
||||
delta = min(max(time.Second, delta*3/2), 5*time.Second).Round(time.Second)
|
||||
|
||||
app.conn.rate = delta
|
||||
app.conn.ticker = time.NewTicker(delta)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue