diff options
Diffstat (limited to 'pkg/commands/unsubscribe.go')
| -rw-r--r-- | pkg/commands/unsubscribe.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/commands/unsubscribe.go b/pkg/commands/unsubscribe.go new file mode 100644 index 0000000..9ca502d --- /dev/null +++ b/pkg/commands/unsubscribe.go @@ -0,0 +1,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 +}
\ No newline at end of file |
