func (c *Connection) Prepare(mechanism SecurityMechanism, socketType SocketType, socketID SocketIdentity, asServer bool, applicationMetadata map[string]string) (map[string]string, error) {
	if c.isPrepared {
		return nil, errors.New("Connection was already prepared")
	}

	c.isPrepared = true
	c.securityMechanism = mechanism

	var err error
	if c.socket, err = NewSocket(socketType); err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while creating socket: %v", err)
	}

	// Send/recv greeting
	if err := c.sendGreeting(asServer); err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while sending greeting: %v", err)
	}
	if err := c.recvGreeting(asServer); err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while receiving greeting: %v", err)
	}

	// Do security handshake
	if err := mechanism.Handshake(); err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while running the security handshake: %v", err)
	}

	// Send/recv metadata
	if err := c.sendMetadata(socketType, socketID, applicationMetadata); err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while sending metadata: %v", err)
	}

	otherEndApplicationMetaData, err := c.recvMetadata()
	if err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while receiving metadata: %v", err)
	}

	return otherEndApplicationMetaData, nil
}
// Prepare performs a ZMTP handshake over a Connection's readWriter
Prepare performs a ZMTP handshake over a Connection's readWriter
// Prepare performs a ZMTP handshake over a Connection ' s readWriter
func (c *Connection) Prepare(mechanism SecurityMechanism, socketType SocketType, socketID SocketIdentity, asServer bool, applicationMetadata map[string]string) (map[string]string, error) {
	if c.isPrepared {
		return nil, errors.New("Connection was already prepared")
	}
	c.isPrepared = true
	c.securityMechanism = mechanism
	var err error
	if c.socket, err = NewSocket(socketType); err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while creating socket: %v", err)
	}
	if err := c.sendGreeting(asServer); err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while sending greeting: %v", err)
	}
	if err := c.recvGreeting(asServer); err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while receiving greeting: %v", err)
	}
	if err := mechanism.Handshake(); err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while running the security handshake: %v", err)
	}
	if err := c.sendMetadata(socketType, socketID, applicationMetadata); err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while sending metadata: %v", err)
	}
	otherEndApplicationMetaData, err := c.recvMetadata()
	if err != nil {
		return nil, fmt.Errorf("gomq/zmtp: Got error while receiving metadata: %v", err)
	}
	return otherEndApplicationMetaData, nil
}
func ( c * Connection ) Prepare ( mechanism SecurityMechanism , socketType SocketType , socketID SocketIdentity , asServer bool , applicationMetadata map [ string ] string ) ( map [ string ] string , error ) { if c . isPrepared { return nil , errors . New ( " " ) } c . isPrepared = true c . securityMechanism = mechanism var err error if c . socket , err = NewSocket ( socketType ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } if err := c . sendGreeting ( asServer ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } if err := c . recvGreeting ( asServer ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } if err := mechanism . Handshake ( ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } if err := c . sendMetadata ( socketType , socketID , applicationMetadata ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } otherEndApplicationMetaData , err := c . recvMetadata ( ) if err != nil { return nil , fmt . Errorf ( " " , err ) } return otherEndApplicationMetaData , nil }
Prepare performs a ZMTP handshake over a Connection's readWriter
Prepare performs a ZMTP handshake over a Connection ' s readWriter
// Send/recv greeting // Do security handshake // Send/recv metadata