Exemplo n.º 1
0
func (s *MexSocket) Send(mex message.Message) (int, error) {

	if s.IsClosed() {
		return 0, errors.New("Impossible to write on closed socket")
	}

	//convert message to byte array
	bytes := mex.ToByteArray()

	//then call the low level writebytes
	n, err := s.WriteBytes(bytes)
	return n, err
}
Exemplo n.º 2
0
func (s *MexSocket) Read(mex message.Message) (int, error) {

	if s.IsClosed() {
		return 0, errors.New("Impossible to read from closed socket")
	}

	//read bytes
	bytes, n, err := s.ReadBytes()

	if err != nil {
		return n, err
	}

	//build a message from the byte read
	err = mex.FromByteArray(bytes)
	return n, err
}