aboutsummaryrefslogtreecommitdiff
path: root/pkg/commands/unsubscribe.go
blob: 9ca502d89980520e43326a4911c147329d7a4fd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package commands

import (
	"net"
	"redisClone/pkg/core"
	"redisClone/pkg/pubsub"
)

func Unsubscribe(hub *pubsub.Hub, conn net.Conn, args []string) interface{}{
	channels := args[1:]
	results := hub.Unsubscribe(conn, channels)

	for channel, remainingCount := range results {
		resp := core.SerializeRESP([]interface{}{"unsubscribe", channel, remainingCount})
		conn.Write(resp)
	}

	return nil
}