package publisher

import (
	"strings"
)

const (
	TopicSeparator = "="

	WsMsgSubscribe         = "subscribe"
	WsMsgSubscribeResult   = "subscribeResult"
	WsMsgUnsubscribe       = "unsubscribe"
	WsMsgUnsubscribeToAll  = "unsubscribeToAll"
	WsMsgMakeConnAsChannel = "makeConnAsChannel"
	WsMsgConnAsChannel     = "connAsChannel"
)

func parseTopic(topic string) (prefix, arg string) {
	pair := strings.SplitN(topic, TopicSeparator, 2)
	prefix = pair[0]
	if len(pair) > 1 {
		arg = pair[1]
	}
	return
}

type SubscribeResult struct {
	Topic   string `json:"topic"`
	Success bool   `json:"success"`
	Reason  string `json:"reason"`
}
