Пример #1
0
func extractSession(s *server.Session) (*proto.Auth, *srvdir_proto.AuthExtra, error) {
	var auth proto.Auth
	if err := proto.UnpackInterfaceField(s.Auth(), &auth); err != nil {
		return nil, nil, err
	}

	var authExtra srvdir_proto.AuthExtra
	if err := proto.UnpackInterfaceField(s.Auth().Extra, &authExtra); err != nil {
		return nil, nil, err
	}

	return &auth, &authExtra, nil
}
Пример #2
0
func (b *TCPBinder) Bind(rawOpts interface{}) (net.Listener, string, error) {
	var opts proto.TCPOptions
	if err := proto.UnpackInterfaceField(rawOpts, &opts); err != nil {
		return nil, "", err
	}

	return b.BindOpts(&opts)
}
Пример #3
0
func UnpackAuthExtra(extra interface{}) (authExtra *AuthExtra, err error) {
	authExtra = new(AuthExtra)
	err = proto.UnpackInterfaceField(extra, authExtra)
	return
}