Skip to content
Closed
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ func Auth(secret string) (*Command, error) {
return &Command{[]byte("AUTH"), nil, []byte(secret)}, nil
}

// Register creates a new Command to add a topic/channel for the connected nsqd
func Register(topic string, channel string) *Command {
params := [][]byte{[]byte(topic)}
if len(channel) > 0 {
params = append(params, []byte(channel))
// Register creates a new Command to add a topic/channel with state for the connected nsqd
func Register(topic string, channel string, states ...[]byte) *Command {
Comment thread
maplessssy marked this conversation as resolved.
Outdated
params := [][]byte{[]byte(topic), []byte(channel)}
if len(states) > 0 {
params = append(params, states[0]) //topic state
if len(states) > 1 {
params = append(params, states[1]) //channel state
}
}
return &Command{[]byte("REGISTER"), params, nil}
}
Expand All @@ -121,6 +124,15 @@ func UnRegister(topic string, channel string) *Command {
return &Command{[]byte("UNREGISTER"), params, nil}
}

// SyncState creates a new Command to sync a topic/channel state changes, like paused, unpaused
func SyncState(topic string, channel string, state []byte) *Command {
Comment thread
maplessssy marked this conversation as resolved.
Outdated
params := [][]byte{state, []byte(topic)}
if len(channel) > 0 {
params = append(params, []byte(channel))
}
return &Command{[]byte("SYNCSTATE"), params, nil}
}

// Ping creates a new Command to keep-alive the state of all the
// announced topic/channels for a given client
func Ping() *Command {
Expand Down