faye protocol always send and ACK for published messages.
remove OnPublishResponse and make publish a blocking function until we receive ACK from server
This commit is contained in:
@ -4,20 +4,20 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Name struct {
|
||||
type SubscriptionName struct {
|
||||
n string
|
||||
patterns []string
|
||||
}
|
||||
|
||||
func NewName(name string) *Name {
|
||||
var n Name
|
||||
func NewName(name string) *SubscriptionName {
|
||||
var n SubscriptionName
|
||||
n.n = name
|
||||
//expand once
|
||||
n.patterns = n.expand()
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n *Name) Match(channel string) bool {
|
||||
func (n *SubscriptionName) Match(channel string) bool {
|
||||
for i := range n.patterns {
|
||||
if n.patterns[i] == channel {
|
||||
return true
|
||||
@ -26,7 +26,7 @@ func (n *Name) Match(channel string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (n *Name) expand() []string {
|
||||
func (n *SubscriptionName) expand() []string {
|
||||
segments := strings.Split(n.n, "/")
|
||||
num_segments := len(segments)
|
||||
patterns := make([]string, num_segments+1)
|
||||
|
@ -10,13 +10,13 @@ type SubscriptionsStore struct {
|
||||
subs map[string][]*subscription.Subscription
|
||||
|
||||
//cache for expanded channel names
|
||||
cache map[string]*Name
|
||||
cache map[string]*SubscriptionName
|
||||
}
|
||||
|
||||
func NewStore(size int) *SubscriptionsStore {
|
||||
return &SubscriptionsStore{
|
||||
subs: make(map[string][]*subscription.Subscription, size),
|
||||
cache: map[string]*Name{},
|
||||
cache: map[string]*SubscriptionName{},
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ func (s *SubscriptionsStore) Add(sub *subscription.Subscription) {
|
||||
func (s *SubscriptionsStore) Match(channel string) []*subscription.Subscription {
|
||||
var (
|
||||
matches []*subscription.Subscription
|
||||
name *Name
|
||||
name *SubscriptionName
|
||||
ok bool
|
||||
)
|
||||
s.mutex.Lock()
|
||||
|
Reference in New Issue
Block a user