|
|
@ -95,7 +95,7 @@ func (h *Hub) start() { |
|
|
|
buffer := buf.New() |
|
|
|
buffer := buf.New() |
|
|
|
var noob int |
|
|
|
var noob int |
|
|
|
var addr *net.UDPAddr |
|
|
|
var addr *net.UDPAddr |
|
|
|
err := buffer.AppendSupplier(func(b []byte) (int, error) { |
|
|
|
err := buffer.Reset(func(b []byte) (int, error) { |
|
|
|
n, nb, _, a, e := ReadUDPMsg(h.conn, b, oobBytes) |
|
|
|
n, nb, _, a, e := ReadUDPMsg(h.conn, b, oobBytes) |
|
|
|
noob = nb |
|
|
|
noob = nb |
|
|
|
addr = a |
|
|
|
addr = a |
|
|
@ -108,6 +108,11 @@ func (h *Hub) start() { |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if buffer.IsEmpty() { |
|
|
|
|
|
|
|
buffer.Release() |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
payload := &Payload{ |
|
|
|
payload := &Payload{ |
|
|
|
Content: buffer, |
|
|
|
Content: buffer, |
|
|
|
Source: net.UDPDestination(net.IPAddress(addr.IP), net.Port(addr.Port)), |
|
|
|
Source: net.UDPDestination(net.IPAddress(addr.IP), net.Port(addr.Port)), |
|
|
@ -124,6 +129,8 @@ func (h *Hub) start() { |
|
|
|
select { |
|
|
|
select { |
|
|
|
case c <- payload: |
|
|
|
case c <- payload: |
|
|
|
default: |
|
|
|
default: |
|
|
|
|
|
|
|
buffer.Release() |
|
|
|
|
|
|
|
payload.Content = nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|