my code broke after i changed this last time and this fixed it
This commit is contained in:
+3
-1
@@ -119,6 +119,8 @@ func (c *Conn) SetProtocolVersion(version int32) (err error) {
|
|||||||
// ActivateReceiveRoutine activates the receive-routine.
|
// ActivateReceiveRoutine activates the receive-routine.
|
||||||
// It ensures that the receive-routine is only started once and creates a buffered channel for packet handling.
|
// It ensures that the receive-routine is only started once and creates a buffered channel for packet handling.
|
||||||
func (c *Conn) ActivateReceiveRoutine() (chSending <-chan any) {
|
func (c *Conn) ActivateReceiveRoutine() (chSending <-chan any) {
|
||||||
|
// This expects you to start a new routine when switching into play state
|
||||||
|
spamLoginTick := c.State() != proto_base.Play
|
||||||
ch := make(chan any, BufferNPackets)
|
ch := make(chan any, BufferNPackets)
|
||||||
go func() {
|
go func() {
|
||||||
ctx := c.Ctx // this prevents c.Ctx being reassigned
|
ctx := c.Ctx // this prevents c.Ctx being reassigned
|
||||||
@@ -127,7 +129,7 @@ func (c *Conn) ActivateReceiveRoutine() (chSending <-chan any) {
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
if c.State() != proto_base.Play {
|
if spamLoginTick {
|
||||||
ch <- LoginTick{}
|
ch <- LoginTick{}
|
||||||
} else {
|
} else {
|
||||||
packet, err := c.Receive()
|
packet, err := c.Receive()
|
||||||
|
|||||||
Reference in New Issue
Block a user