Example #1
0
// Parses messages from the client
func (p *MessageParser) CsParse(reader io.Reader, logger *log.Logger) {
	p.logger = logger

	// If we return, we should consume all input to avoid blocking the pipe
	// we're listening on. TODO Maybe we could just close it?
	defer p.consumeUnrecognizedInput(reader)

	defer func() {
		if err := recover(); err != nil {
			p.printf("Parsing failed: %v", err)
		}
	}()

	for {
		err := proto.ServerReadPacket(reader, p)
		if err != nil {
			if err != os.EOF {
				p.printf("ReceiveLoop failed: %v", err)
			} else {
				p.printf("ReceiveLoop hit EOF")
			}
			return
		}
	}
}
Example #2
0
func (player *Player) receiveLoop() {
	player.rxRunning = true
	for player.rxRunning {
		err := proto.ServerReadPacket(player.conn, player)
		if err != nil {
			player.rxErrChan <- err
			return
		}
	}
}
Example #3
0
func (player *Player) receiveLoop() {
	for {
		err := proto.ServerReadPacket(player.conn, player)
		if err != nil {
			if err != os.EOF {
				log.Print("ReceiveLoop failed: ", err.String())
			}
			return
		}
	}
}