Skip to content

Commit 5d805e2

Browse files
committed
randomize first clientId
1 parent d3fb970 commit 5d805e2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

host.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package enet
33
import (
44
"bytes"
55
"encoding/binary"
6+
"math/rand"
67
"net"
78
"os"
89
"os/signal"
@@ -39,13 +40,14 @@ func NewHost(addr string) (Host, error) {
3940
ep, err := net.ResolveUDPAddr("udp", addr)
4041

4142
host := &enet_host{
42-
fail: 0,
43-
addr: ep,
44-
incoming: make(chan *enet_host_incoming_command, 16),
45-
outgoing: make(chan *enet_host_outgoing_command, 16),
46-
tick: time.Tick(time.Millisecond * enet_default_tick_ms),
47-
peers: make(map[string]*enet_peer),
48-
timers: new_enet_timer_queue(),
43+
fail: 0,
44+
addr: ep,
45+
incoming: make(chan *enet_host_incoming_command, 16),
46+
outgoing: make(chan *enet_host_outgoing_command, 16),
47+
tick: time.Tick(time.Millisecond * enet_default_tick_ms),
48+
peers: make(map[string]*enet_peer),
49+
timers: new_enet_timer_queue(),
50+
next_clientid: rand.Uint32(),
4951
}
5052
if err == nil {
5153
host.socket, err = net.ListenUDP("udp", ep)

0 commit comments

Comments
 (0)