func WriteProtobuf(conn *transport.Conn, message *proto.ClientToServer) error { unpadMsg, err := protobuf.Marshal(message) if err != nil { return err } _, err = conn.WriteFrame(proto.Pad(unpadMsg, proto.SERVER_MESSAGE_SIZE)) return err }
func writeProtobuf(conn *transport.Conn, outBuf []byte, message *proto.ClientToServer, t *testing.T) { unpadMsg, err := protobuf.Marshal(message) handleError(err, t) padMsg := proto.Pad(unpadMsg, proto.SERVER_MESSAGE_SIZE) copy(outBuf, padMsg) conn.WriteFrame(outBuf[:proto.SERVER_MESSAGE_SIZE]) }
func (server *Server) writeProtobuf(conn *transport.Conn, outBuf []byte, message *proto.ServerToClient) error { unpadMsg, err := protobuf.Marshal(message) if err != nil { return err } padMsg := proto.Pad(unpadMsg, proto.SERVER_MESSAGE_SIZE) copy(outBuf, padMsg) conn.WriteFrame(outBuf[:proto.SERVER_MESSAGE_SIZE]) return nil }