Working authenticated connection

This commit is contained in:
2023-09-18 20:58:15 -05:00
parent 11b176dcbc
commit c89756630f
10 changed files with 126 additions and 62 deletions

View File

@ -2,7 +2,7 @@ package subscription
import (
"errors"
"github.com/thesyncim/faye/message"
"github.com/thesyncim/fayec/message"
"regexp"
)
@ -16,7 +16,7 @@ type Subscription struct {
msgCh chan *message.Message
}
//todo error
// todo error
func NewSubscription(chanel string, unsub Unsubscriber, msgCh chan *message.Message) (*Subscription, error) {
if !IsValidSubscriptionName(chanel) {
return nil, ErrInvalidChannelName
@ -47,12 +47,12 @@ func (s *Subscription) Name() string {
return s.channel
}
//Unsubscribe ...
// Unsubscribe ...
func (s *Subscription) Unsubscribe() error {
return s.unsub(s)
}
//validChannelName channel specifies is the channel is in the format /foo/432/bar
// validChannelName channel specifies is the channel is in the format /foo/432/bar
var validChannelName = regexp.MustCompile(`^\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$`)
var validChannelPattern = regexp.MustCompile(`^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$`)
@ -61,7 +61,7 @@ func IsValidSubscriptionName(channel string) bool {
return validChannelName.MatchString(channel) || validChannelPattern.MatchString(channel)
}
//isValidPublishName
// isValidPublishName
func IsValidPublishName(channel string) bool {
return validChannelName.MatchString(channel)
}