-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Felix Gateru <[email protected]>
- Loading branch information
1 parent
153d230
commit b39d060
Showing
31 changed files
with
958 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright (c) Abstract Machines | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package api contains API-related concerns: endpoint definitions, middlewares | ||
// Package api contains API-related concerns: endpoint definitions | ||
// and all resource representations. | ||
package api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) Abstract Machines | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package events provides the domain concept definitions needed to support | ||
// coap events functionality. | ||
package events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) Abstract Machines | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package events | ||
|
||
const ( | ||
coapPrefix = "coap" | ||
clientPublish = coapPrefix + ".client_publish" | ||
clientSubscribe = coapPrefix + ".client_subscribe" | ||
clientUnsubscribe = coapPrefix + ".client_unsubscribe" | ||
) | ||
|
||
type clientPublishEvent struct { | ||
ChannelID string | ||
ClientID string | ||
Topic string | ||
} | ||
|
||
func (cpe clientPublishEvent) Encode() (map[string]interface{}, error) { | ||
val := map[string]interface{}{ | ||
"operation": clientPublish, | ||
"channel_id": cpe.ChannelID, | ||
"client_id": cpe.ClientID, | ||
"topic": cpe.Topic, | ||
} | ||
return val, nil | ||
} | ||
|
||
type clientSubscribeEvent struct { | ||
ChannelID string | ||
ClientID string | ||
Topic string | ||
} | ||
|
||
func (cse clientSubscribeEvent) Encode() (map[string]interface{}, error) { | ||
val := map[string]interface{}{ | ||
"operation": clientSubscribe, | ||
"channel_id": cse.ChannelID, | ||
"client_id": cse.ClientID, | ||
"topic": cse.Topic, | ||
} | ||
return val, nil | ||
} | ||
|
||
type clientUnsubscribeEvent struct { | ||
ChannelID string | ||
ClientID string | ||
Topic string | ||
} | ||
|
||
func (cse clientUnsubscribeEvent) Encode() (map[string]interface{}, error) { | ||
val := map[string]interface{}{ | ||
"operation": clientUnsubscribe, | ||
"channel_id": cse.ChannelID, | ||
"client_id": cse.ClientID, | ||
"topic": cse.Topic, | ||
} | ||
return val, nil | ||
} |
Oops, something went wrong.