func (c *Connection) RecvMultipart(messageOut chan<- *Message) {
	go func() {
		for {
			// Actually read out the body and send it over the channel now
			isCommand, body, err := c.readMultipart()
			if err != nil {
				messageOut <- &Message{Err: err, MessageType: ErrorMessage}
				return
			}

			if !isCommand {
				// Data frame
				messageOut <- &Message{Body: body, MessageType: UserMessage}
			} else {
				command, err := c.parseCommand(body[0])
				if err != nil {
					messageOut <- &Message{Err: err, MessageType: ErrorMessage}
					return
				}

				// Check what type of command we got
				// Certain commands we deal with directly, the rest we send over to the application
				switch command.Name {
				case "PING":
					// When we get a ping, we want to send back a pong, we don't really care about the contents right now
					if err := c.SendCommand("PONG", nil); err != nil {
						messageOut <- &Message{Err: err, MessageType: ErrorMessage}
						return
					}
				default:
					frames := [][]byte{command.Body}
					messageOut <- &Message{Name: command.Name, Body: frames, MessageType: ErrorMessage}
				}

			}
		}
	}()
}
// RecvMultipart starts listening to the ReadWriter and passes *Message to a channel
RecvMultipart starts listening to the ReadWriter and passes *Message to a channel
// RecvMultipart starts listening to the ReadWriter and passes * Message to a channel
func (c *Connection) RecvMultipart(messageOut chan<- *Message) {
	go func() {
		for {
			isCommand, body, err := c.readMultipart()
			if err != nil {
				messageOut <- &Message{Err: err, MessageType: ErrorMessage}
				return
			}
			if !isCommand {
				messageOut <- &Message{Body: body, MessageType: UserMessage}
			} else {
				command, err := c.parseCommand(body[0])
				if err != nil {
					messageOut <- &Message{Err: err, MessageType: ErrorMessage}
					return
				}
				switch command.Name {
				case "PING":
					if err := c.SendCommand("PONG", nil); err != nil {
						messageOut <- &Message{Err: err, MessageType: ErrorMessage}
						return
					}
				default:
					frames := [][]byte{command.Body}
					messageOut <- &Message{Name: command.Name, Body: frames, MessageType: ErrorMessage}
				}
			}
		}
	}()
}
func ( c * Connection ) RecvMultipart ( messageOut chan <- * Message ) { go func ( ) { for { isCommand , body , err := c . readMultipart ( ) if err != nil { messageOut <- & Message { Err : err , MessageType : ErrorMessage } return } if ! isCommand { messageOut <- & Message { Body : body , MessageType : UserMessage } } else { command , err := c . parseCommand ( body [ 0 ] ) if err != nil { messageOut <- & Message { Err : err , MessageType : ErrorMessage } return } switch command . Name { case " " : if err := c . SendCommand ( " " , nil ) ; err != nil { messageOut <- & Message { Err : err , MessageType : ErrorMessage } return } default : frames := [ ] [ ] byte { command . Body } messageOut <- & Message { Name : command . Name , Body : frames , MessageType : ErrorMessage } } } } } ( ) }
RecvMultipart starts listening to the ReadWriter and passes *Message to a channel
RecvMultipart starts listening to the ReadWriter and passes * Message to a channel
// Actually read out the body and send it over the channel now // Data frame // Check what type of command we got // Certain commands we deal with directly, the rest we send over to the application // When we get a ping, we want to send back a pong, we don't really care about the contents right now