From 10d75dc3a0ac1f2ba4b588552e4656fab40bdbd0 Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Sat, 29 Jun 2024 16:36:37 +0500 Subject: [PATCH 1/7] Add command for Subscribe message --- cmd/wampproto/main.go | 21 +++++++++++++++++++++ cmd/wampproto/main_test.go | 15 +++++++++++++++ cmd/wampproto/messages.go | 7 +++++++ 3 files changed, 43 insertions(+) diff --git a/cmd/wampproto/main.go b/cmd/wampproto/main.go index 27dadf8..127cdcb 100644 --- a/cmd/wampproto/main.go +++ b/cmd/wampproto/main.go @@ -36,6 +36,7 @@ type cmd struct { *Yield *UnRegister *UnRegistered + *Subscribe } func parseCmd(args []string) (*cmd, error) { @@ -59,6 +60,7 @@ func parseCmd(args []string) (*cmd, error) { yieldCommand := messageCommand.Command("yield", "Yield message.") UnRegisterCommand := messageCommand.Command("unregister", "Unregister message.") UnRegisteredCommand := messageCommand.Command("unregistered", "Unregistered message.") + subscribeCommand := messageCommand.Command("subscribe", "Subscribe message.") c := &cmd{ output: app.Flag("output", "Format of the output.").Default("hex"). Enum(wampprotocli.HexFormat, wampprotocli.Base64Format), @@ -146,6 +148,13 @@ func parseCmd(args []string) (*cmd, error) { unRegistered: UnRegisteredCommand, UnRegisteredRequestID: UnRegisteredCommand.Arg("request-id", "UnRegistered request ID.").Required().Int64(), }, + + Subscribe: &Subscribe{ + subscribe: subscribeCommand, + subscribeRequestID: subscribeCommand.Arg("request-id", "Subscribe request ID.").Required().Int64(), + subscribeTopic: subscribeCommand.Arg("topic", "Topic to subscribe.").Required().String(), + subscribeOptions: subscribeCommand.Flag("option", "Subscribe options.").Short('o').StringMap(), + }, } parsedCommand, err := app.Parse(args[1:]) @@ -332,6 +341,18 @@ func Run(args []string) (string, error) { unRegisteredMessage := messages.NewUnRegistered(*c.UnRegisteredRequestID) return serializeMessageAndOutput(serializer, unRegisteredMessage, *c.output) + + case c.subscribe.FullCommand(): + var ( + subscribeOptions = wampprotocli.StringMapToTypedMap(*c.subscribeOptions) + + serializer = wampprotocli.SerializerByName(*c.serializer) + ) + + subscribeMessage := messages.NewSubscribe(*c.subscribeRequestID, subscribeOptions, *c.subscribeTopic) + + return serializeMessageAndOutput(serializer, subscribeMessage, *c.output) + } return "", nil diff --git a/cmd/wampproto/main_test.go b/cmd/wampproto/main_test.go index 713f488..58b59b0 100644 --- a/cmd/wampproto/main_test.go +++ b/cmd/wampproto/main_test.go @@ -344,3 +344,18 @@ func TestUnRegisteredMessage(t *testing.T) { testMessageCommand(t, command) } + +func TestSubscribeMessage(t *testing.T) { + var command = "wampproto message subscribe 1 test" + + testMessageCommand(t, command) + + t.Run("WithOptions", func(t *testing.T) { + var cmd = command + " -o invoke=roundrobin" + output, err := main.Run(strings.Split(cmd, " ")) + require.NoError(t, err) + + _, err = hex.DecodeString(output) + require.NoError(t, err) + }) +} diff --git a/cmd/wampproto/messages.go b/cmd/wampproto/messages.go index 8e6a341..8a2fbb8 100644 --- a/cmd/wampproto/messages.go +++ b/cmd/wampproto/messages.go @@ -61,3 +61,10 @@ type UnRegistered struct { unRegistered *kingpin.CmdClause UnRegisteredRequestID *int64 } + +type Subscribe struct { + subscribe *kingpin.CmdClause + subscribeRequestID *int64 + subscribeTopic *string + subscribeOptions *map[string]string +} From c27136ec2b8a0aa127858e38a82ea2d70965c659 Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Sat, 29 Jun 2024 16:41:08 +0500 Subject: [PATCH 2/7] Add command for Subscribed message --- cmd/wampproto/main.go | 15 +++++++++++++++ cmd/wampproto/main_test.go | 6 ++++++ cmd/wampproto/messages.go | 6 ++++++ 3 files changed, 27 insertions(+) diff --git a/cmd/wampproto/main.go b/cmd/wampproto/main.go index 127cdcb..a5d0d8b 100644 --- a/cmd/wampproto/main.go +++ b/cmd/wampproto/main.go @@ -37,6 +37,7 @@ type cmd struct { *UnRegister *UnRegistered *Subscribe + *Subscribed } func parseCmd(args []string) (*cmd, error) { @@ -61,6 +62,7 @@ func parseCmd(args []string) (*cmd, error) { UnRegisterCommand := messageCommand.Command("unregister", "Unregister message.") UnRegisteredCommand := messageCommand.Command("unregistered", "Unregistered message.") subscribeCommand := messageCommand.Command("subscribe", "Subscribe message.") + subscribedCommand := messageCommand.Command("subscribed", "Subscribed message.") c := &cmd{ output: app.Flag("output", "Format of the output.").Default("hex"). Enum(wampprotocli.HexFormat, wampprotocli.Base64Format), @@ -155,6 +157,12 @@ func parseCmd(args []string) (*cmd, error) { subscribeTopic: subscribeCommand.Arg("topic", "Topic to subscribe.").Required().String(), subscribeOptions: subscribeCommand.Flag("option", "Subscribe options.").Short('o').StringMap(), }, + + Subscribed: &Subscribed{ + subscribed: subscribedCommand, + subscribedRequestID: subscribedCommand.Arg("request-id", "Subscribed request ID.").Required().Int64(), + subscriptionID: subscribedCommand.Arg("subscription-id", "Subscription ID.").Required().Int64(), + }, } parsedCommand, err := app.Parse(args[1:]) @@ -353,6 +361,13 @@ func Run(args []string) (string, error) { return serializeMessageAndOutput(serializer, subscribeMessage, *c.output) + case c.subscribed.FullCommand(): + var serializer = wampprotocli.SerializerByName(*c.serializer) + + subscribedMessage := messages.NewSubscribed(*c.subscribedRequestID, *c.subscriptionID) + + return serializeMessageAndOutput(serializer, subscribedMessage, *c.output) + } return "", nil diff --git a/cmd/wampproto/main_test.go b/cmd/wampproto/main_test.go index 58b59b0..5ab587c 100644 --- a/cmd/wampproto/main_test.go +++ b/cmd/wampproto/main_test.go @@ -359,3 +359,9 @@ func TestSubscribeMessage(t *testing.T) { require.NoError(t, err) }) } + +func TestSubscribedMessage(t *testing.T) { + var command = "wampproto message subscribed 1 1" + + testMessageCommand(t, command) +} diff --git a/cmd/wampproto/messages.go b/cmd/wampproto/messages.go index 8a2fbb8..914705e 100644 --- a/cmd/wampproto/messages.go +++ b/cmd/wampproto/messages.go @@ -68,3 +68,9 @@ type Subscribe struct { subscribeTopic *string subscribeOptions *map[string]string } + +type Subscribed struct { + subscribed *kingpin.CmdClause + subscribedRequestID *int64 + subscriptionID *int64 +} From cfd75a9782c97c00dd924b68a0bc75898dadba95 Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Sat, 29 Jun 2024 16:49:31 +0500 Subject: [PATCH 3/7] Add command for Publish message --- cmd/wampproto/main.go | 25 +++++++++++++++++++++++++ cmd/wampproto/main_test.go | 15 +++++++++++++++ cmd/wampproto/messages.go | 9 +++++++++ 3 files changed, 49 insertions(+) diff --git a/cmd/wampproto/main.go b/cmd/wampproto/main.go index a5d0d8b..87378de 100644 --- a/cmd/wampproto/main.go +++ b/cmd/wampproto/main.go @@ -38,6 +38,7 @@ type cmd struct { *UnRegistered *Subscribe *Subscribed + *Publish } func parseCmd(args []string) (*cmd, error) { @@ -63,6 +64,7 @@ func parseCmd(args []string) (*cmd, error) { UnRegisteredCommand := messageCommand.Command("unregistered", "Unregistered message.") subscribeCommand := messageCommand.Command("subscribe", "Subscribe message.") subscribedCommand := messageCommand.Command("subscribed", "Subscribed message.") + publishCommand := messageCommand.Command("publish", "Publish message.") c := &cmd{ output: app.Flag("output", "Format of the output.").Default("hex"). Enum(wampprotocli.HexFormat, wampprotocli.Base64Format), @@ -163,6 +165,15 @@ func parseCmd(args []string) (*cmd, error) { subscribedRequestID: subscribedCommand.Arg("request-id", "Subscribed request ID.").Required().Int64(), subscriptionID: subscribedCommand.Arg("subscription-id", "Subscription ID.").Required().Int64(), }, + + Publish: &Publish{ + publish: publishCommand, + publishRequestID: publishCommand.Arg("request-id", "Publish request ID.").Required().Int64(), + publishTopic: publishCommand.Arg("topic", "Publish topic.").Required().String(), + publishOptions: publishCommand.Flag("option", "Publish options.").Short('o').StringMap(), + publishArgs: publishCommand.Arg("args", "Publish arguments.").Strings(), + publishKwArgs: publishCommand.Flag("kwargs", "Publish Keyword arguments.").Short('k').StringMap(), + }, } parsedCommand, err := app.Parse(args[1:]) @@ -368,6 +379,20 @@ func Run(args []string) (string, error) { return serializeMessageAndOutput(serializer, subscribedMessage, *c.output) + case c.publish.FullCommand(): + var ( + publishOptions = wampprotocli.StringMapToTypedMap(*c.publishOptions) + publishArgs = wampprotocli.StringsToTypedList(*c.publishArgs) + publishKwargs = wampprotocli.StringMapToTypedMap(*c.publishKwArgs) + + serializer = wampprotocli.SerializerByName(*c.serializer) + ) + + publishMessage := messages.NewPublish(*c.publishRequestID, publishOptions, *c.publishTopic, publishArgs, + publishKwargs) + + return serializeMessageAndOutput(serializer, publishMessage, *c.output) + } return "", nil diff --git a/cmd/wampproto/main_test.go b/cmd/wampproto/main_test.go index 5ab587c..4aadbd4 100644 --- a/cmd/wampproto/main_test.go +++ b/cmd/wampproto/main_test.go @@ -365,3 +365,18 @@ func TestSubscribedMessage(t *testing.T) { testMessageCommand(t, command) } + +func TestPublishMessage(t *testing.T) { + var command = "wampproto message publish 1 1" + + testMessageCommand(t, command) + + t.Run("WithArgsKwargsOptions", func(t *testing.T) { + var cmd = command + " abc def -o abc=def -k key:value abc=123" + output, err := main.Run(strings.Split(cmd, " ")) + require.NoError(t, err) + + _, err = hex.DecodeString(output) + require.NoError(t, err) + }) +} diff --git a/cmd/wampproto/messages.go b/cmd/wampproto/messages.go index 914705e..4c48b31 100644 --- a/cmd/wampproto/messages.go +++ b/cmd/wampproto/messages.go @@ -74,3 +74,12 @@ type Subscribed struct { subscribedRequestID *int64 subscriptionID *int64 } + +type Publish struct { + publish *kingpin.CmdClause + publishRequestID *int64 + publishTopic *string + publishOptions *map[string]string + publishArgs *[]string + publishKwArgs *map[string]string +} From 2040123d523d7d94ce117e7dfe2b237dd726ff08 Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Sat, 29 Jun 2024 16:55:26 +0500 Subject: [PATCH 4/7] Add command for Published message --- cmd/wampproto/main.go | 14 ++++++++++++++ cmd/wampproto/main_test.go | 6 ++++++ cmd/wampproto/messages.go | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/cmd/wampproto/main.go b/cmd/wampproto/main.go index 87378de..aa9c1c2 100644 --- a/cmd/wampproto/main.go +++ b/cmd/wampproto/main.go @@ -39,6 +39,7 @@ type cmd struct { *Subscribe *Subscribed *Publish + *Published } func parseCmd(args []string) (*cmd, error) { @@ -65,6 +66,7 @@ func parseCmd(args []string) (*cmd, error) { subscribeCommand := messageCommand.Command("subscribe", "Subscribe message.") subscribedCommand := messageCommand.Command("subscribed", "Subscribed message.") publishCommand := messageCommand.Command("publish", "Publish message.") + publishedCommand := messageCommand.Command("published", "Published message.") c := &cmd{ output: app.Flag("output", "Format of the output.").Default("hex"). Enum(wampprotocli.HexFormat, wampprotocli.Base64Format), @@ -174,6 +176,12 @@ func parseCmd(args []string) (*cmd, error) { publishArgs: publishCommand.Arg("args", "Publish arguments.").Strings(), publishKwArgs: publishCommand.Flag("kwargs", "Publish Keyword arguments.").Short('k').StringMap(), }, + + Published: &Published{ + published: publishedCommand, + publishedRequestID: publishedCommand.Arg("request-id", "Published request ID.").Required().Int64(), + publicationID: publishedCommand.Arg("publication-id", "Publication ID.").Required().Int64(), + }, } parsedCommand, err := app.Parse(args[1:]) @@ -393,6 +401,12 @@ func Run(args []string) (string, error) { return serializeMessageAndOutput(serializer, publishMessage, *c.output) + case c.published.FullCommand(): + var serializer = wampprotocli.SerializerByName(*c.serializer) + + publishedMessage := messages.NewPublished(*c.publishedRequestID, *c.publicationID) + + return serializeMessageAndOutput(serializer, publishedMessage, *c.output) } return "", nil diff --git a/cmd/wampproto/main_test.go b/cmd/wampproto/main_test.go index 4aadbd4..0f08106 100644 --- a/cmd/wampproto/main_test.go +++ b/cmd/wampproto/main_test.go @@ -380,3 +380,9 @@ func TestPublishMessage(t *testing.T) { require.NoError(t, err) }) } + +func TestPublishedMessage(t *testing.T) { + var command = "wampproto message published 1 1" + + testMessageCommand(t, command) +} diff --git a/cmd/wampproto/messages.go b/cmd/wampproto/messages.go index 4c48b31..6d271d9 100644 --- a/cmd/wampproto/messages.go +++ b/cmd/wampproto/messages.go @@ -83,3 +83,9 @@ type Publish struct { publishArgs *[]string publishKwArgs *map[string]string } + +type Published struct { + published *kingpin.CmdClause + publishedRequestID *int64 + publicationID *int64 +} From 67883ccec3cc1b08ae0c0a9c0b0a4e134d938e55 Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Sat, 29 Jun 2024 17:14:28 +0500 Subject: [PATCH 5/7] Add command for Event message --- cmd/wampproto/main.go | 26 +++++++++++++++++++++++++- cmd/wampproto/main_test.go | 15 +++++++++++++++ cmd/wampproto/messages.go | 9 +++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/cmd/wampproto/main.go b/cmd/wampproto/main.go index aa9c1c2..9341243 100644 --- a/cmd/wampproto/main.go +++ b/cmd/wampproto/main.go @@ -40,6 +40,7 @@ type cmd struct { *Subscribed *Publish *Published + *Event } func parseCmd(args []string) (*cmd, error) { @@ -67,6 +68,7 @@ func parseCmd(args []string) (*cmd, error) { subscribedCommand := messageCommand.Command("subscribed", "Subscribed message.") publishCommand := messageCommand.Command("publish", "Publish message.") publishedCommand := messageCommand.Command("published", "Published message.") + eventCommand := messageCommand.Command("event", "Event message.") c := &cmd{ output: app.Flag("output", "Format of the output.").Default("hex"). Enum(wampprotocli.HexFormat, wampprotocli.Base64Format), @@ -174,7 +176,7 @@ func parseCmd(args []string) (*cmd, error) { publishTopic: publishCommand.Arg("topic", "Publish topic.").Required().String(), publishOptions: publishCommand.Flag("option", "Publish options.").Short('o').StringMap(), publishArgs: publishCommand.Arg("args", "Publish arguments.").Strings(), - publishKwArgs: publishCommand.Flag("kwargs", "Publish Keyword arguments.").Short('k').StringMap(), + publishKwArgs: publishCommand.Flag("kwarg", "Publish Keyword arguments.").Short('k').StringMap(), }, Published: &Published{ @@ -182,6 +184,15 @@ func parseCmd(args []string) (*cmd, error) { publishedRequestID: publishedCommand.Arg("request-id", "Published request ID.").Required().Int64(), publicationID: publishedCommand.Arg("publication-id", "Publication ID.").Required().Int64(), }, + + Event: &Event{ + event: eventCommand, + eventSubscriptionID: eventCommand.Arg("subscription-id", "Event subscription ID.").Required().Int64(), + eventPublicationID: eventCommand.Arg("publication-id", "Event publication ID.").Required().Int64(), + eventDetails: eventCommand.Flag("detail", "Event details.").Short('d').StringMap(), + eventArgs: eventCommand.Arg("args", "Event arguments.").Strings(), + eventKwArgs: eventCommand.Flag("kwarg", "Event Keyword arguments.").Short('k').StringMap(), + }, } parsedCommand, err := app.Parse(args[1:]) @@ -407,6 +418,19 @@ func Run(args []string) (string, error) { publishedMessage := messages.NewPublished(*c.publishedRequestID, *c.publicationID) return serializeMessageAndOutput(serializer, publishedMessage, *c.output) + + case c.event.FullCommand(): + var ( + eventDetails = wampprotocli.StringMapToTypedMap(*c.eventDetails) + eventArgs = wampprotocli.StringsToTypedList(*c.eventArgs) + eventKwargs = wampprotocli.StringMapToTypedMap(*c.eventKwArgs) + + serializer = wampprotocli.SerializerByName(*c.serializer) + ) + + eventMessage := messages.NewEvent(*c.subscriptionID, *c.publishRequestID, eventDetails, eventArgs, eventKwargs) + + return serializeMessageAndOutput(serializer, eventMessage, *c.output) } return "", nil diff --git a/cmd/wampproto/main_test.go b/cmd/wampproto/main_test.go index 0f08106..4e5bf0a 100644 --- a/cmd/wampproto/main_test.go +++ b/cmd/wampproto/main_test.go @@ -386,3 +386,18 @@ func TestPublishedMessage(t *testing.T) { testMessageCommand(t, command) } + +func TestEventMessage(t *testing.T) { + var command = "wampproto message event 1 1" + + testMessageCommand(t, command) + + t.Run("WithArgsKwargsDetails", func(t *testing.T) { + var cmd = command + " abc def -d abc=def -k key:value abc=123" + output, err := main.Run(strings.Split(cmd, " ")) + require.NoError(t, err) + + _, err = hex.DecodeString(output) + require.NoError(t, err) + }) +} diff --git a/cmd/wampproto/messages.go b/cmd/wampproto/messages.go index 6d271d9..a733567 100644 --- a/cmd/wampproto/messages.go +++ b/cmd/wampproto/messages.go @@ -89,3 +89,12 @@ type Published struct { publishedRequestID *int64 publicationID *int64 } + +type Event struct { + event *kingpin.CmdClause + eventSubscriptionID *int64 + eventPublicationID *int64 + eventDetails *map[string]string + eventArgs *[]string + eventKwArgs *map[string]string +} From 64c6fca3f869203d3f923c0f90375149ddd1fc62 Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Sat, 29 Jun 2024 17:20:51 +0500 Subject: [PATCH 6/7] Add command for UnSubscribe message --- cmd/wampproto/main.go | 16 ++++++++++++++++ cmd/wampproto/main_test.go | 6 ++++++ cmd/wampproto/messages.go | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/cmd/wampproto/main.go b/cmd/wampproto/main.go index 9341243..b70384b 100644 --- a/cmd/wampproto/main.go +++ b/cmd/wampproto/main.go @@ -41,6 +41,7 @@ type cmd struct { *Publish *Published *Event + *UnSubscribe } func parseCmd(args []string) (*cmd, error) { @@ -69,6 +70,7 @@ func parseCmd(args []string) (*cmd, error) { publishCommand := messageCommand.Command("publish", "Publish message.") publishedCommand := messageCommand.Command("published", "Published message.") eventCommand := messageCommand.Command("event", "Event message.") + unSubscribeCommand := messageCommand.Command("unsubscribe", "Unsubscribe message.") c := &cmd{ output: app.Flag("output", "Format of the output.").Default("hex"). Enum(wampprotocli.HexFormat, wampprotocli.Base64Format), @@ -193,6 +195,13 @@ func parseCmd(args []string) (*cmd, error) { eventArgs: eventCommand.Arg("args", "Event arguments.").Strings(), eventKwArgs: eventCommand.Flag("kwarg", "Event Keyword arguments.").Short('k').StringMap(), }, + + UnSubscribe: &UnSubscribe{ + unSubscribe: unSubscribeCommand, + unSubscribeRequestID: unSubscribeCommand.Arg("request-id", "UnSubscribe request ID.").Required().Int64(), + unSubscribeSubscriptionID: unSubscribeCommand.Arg("subscription-id", "UnSubscribe subscription ID."). + Required().Int64(), + }, } parsedCommand, err := app.Parse(args[1:]) @@ -431,6 +440,13 @@ func Run(args []string) (string, error) { eventMessage := messages.NewEvent(*c.subscriptionID, *c.publishRequestID, eventDetails, eventArgs, eventKwargs) return serializeMessageAndOutput(serializer, eventMessage, *c.output) + + case c.unSubscribe.FullCommand(): + var serializer = wampprotocli.SerializerByName(*c.serializer) + + unSubscribeMessage := messages.NewUnSubscribe(*c.unSubscribeRequestID, *c.unSubscribeSubscriptionID) + + return serializeMessageAndOutput(serializer, unSubscribeMessage, *c.output) } return "", nil diff --git a/cmd/wampproto/main_test.go b/cmd/wampproto/main_test.go index 4e5bf0a..247878a 100644 --- a/cmd/wampproto/main_test.go +++ b/cmd/wampproto/main_test.go @@ -401,3 +401,9 @@ func TestEventMessage(t *testing.T) { require.NoError(t, err) }) } + +func TestUnSubscribeMessage(t *testing.T) { + var command = "wampproto message unsubscribe 1 1" + + testMessageCommand(t, command) +} diff --git a/cmd/wampproto/messages.go b/cmd/wampproto/messages.go index a733567..d841a78 100644 --- a/cmd/wampproto/messages.go +++ b/cmd/wampproto/messages.go @@ -98,3 +98,9 @@ type Event struct { eventArgs *[]string eventKwArgs *map[string]string } + +type UnSubscribe struct { + unSubscribe *kingpin.CmdClause + unSubscribeRequestID *int64 + unSubscribeSubscriptionID *int64 +} From b4e01cc76b56967212fe680225ac9a0e8788b2e6 Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Sat, 29 Jun 2024 17:23:42 +0500 Subject: [PATCH 7/7] Add command for UnSubscribed message --- cmd/wampproto/main.go | 15 +++++++++++++++ cmd/wampproto/main_test.go | 6 ++++++ cmd/wampproto/messages.go | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/cmd/wampproto/main.go b/cmd/wampproto/main.go index b70384b..92fa69b 100644 --- a/cmd/wampproto/main.go +++ b/cmd/wampproto/main.go @@ -42,6 +42,7 @@ type cmd struct { *Published *Event *UnSubscribe + *UnSubscribed } func parseCmd(args []string) (*cmd, error) { @@ -71,6 +72,7 @@ func parseCmd(args []string) (*cmd, error) { publishedCommand := messageCommand.Command("published", "Published message.") eventCommand := messageCommand.Command("event", "Event message.") unSubscribeCommand := messageCommand.Command("unsubscribe", "Unsubscribe message.") + unSubscribedCommand := messageCommand.Command("unsubscribed", "Unsubscribed message.") c := &cmd{ output: app.Flag("output", "Format of the output.").Default("hex"). Enum(wampprotocli.HexFormat, wampprotocli.Base64Format), @@ -202,6 +204,11 @@ func parseCmd(args []string) (*cmd, error) { unSubscribeSubscriptionID: unSubscribeCommand.Arg("subscription-id", "UnSubscribe subscription ID."). Required().Int64(), }, + + UnSubscribed: &UnSubscribed{ + unSubscribed: unSubscribedCommand, + unSubscribedRequestID: unSubscribedCommand.Arg("request-id", "UnSubscribed request ID.").Required().Int64(), + }, } parsedCommand, err := app.Parse(args[1:]) @@ -447,6 +454,14 @@ func Run(args []string) (string, error) { unSubscribeMessage := messages.NewUnSubscribe(*c.unSubscribeRequestID, *c.unSubscribeSubscriptionID) return serializeMessageAndOutput(serializer, unSubscribeMessage, *c.output) + + case c.unSubscribed.FullCommand(): + var serializer = wampprotocli.SerializerByName(*c.serializer) + + unSubscribedMessage := messages.NewUnSubscribed(*c.unSubscribedRequestID) + + return serializeMessageAndOutput(serializer, unSubscribedMessage, *c.output) + } return "", nil diff --git a/cmd/wampproto/main_test.go b/cmd/wampproto/main_test.go index 247878a..75f285b 100644 --- a/cmd/wampproto/main_test.go +++ b/cmd/wampproto/main_test.go @@ -407,3 +407,9 @@ func TestUnSubscribeMessage(t *testing.T) { testMessageCommand(t, command) } + +func TestUnSubscribedMessage(t *testing.T) { + var command = "wampproto message unsubscribed 1" + + testMessageCommand(t, command) +} diff --git a/cmd/wampproto/messages.go b/cmd/wampproto/messages.go index d841a78..810c860 100644 --- a/cmd/wampproto/messages.go +++ b/cmd/wampproto/messages.go @@ -104,3 +104,8 @@ type UnSubscribe struct { unSubscribeRequestID *int64 unSubscribeSubscriptionID *int64 } + +type UnSubscribed struct { + unSubscribed *kingpin.CmdClause + unSubscribedRequestID *int64 +}