Working authenticated connection
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user