summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gopackage/ddp/ddp_messages.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-02-10 17:00:11 +0100
committerWim <wim@42.be>2019-02-15 18:19:34 +0100
commit6ebd5cbbd8a941e0bc5f99f0d8e99cfd1d8ac0d7 (patch)
tree47070e58e7802afd80fce53f0048a87a014a7c0d /vendor/github.com/gopackage/ddp/ddp_messages.go
parent2cfd880cdb0df29771bf8f31df8d990ab897889d (diff)
downloadmatterbridge-msglm-6ebd5cbbd8a941e0bc5f99f0d8e99cfd1d8ac0d7.tar.gz
matterbridge-msglm-6ebd5cbbd8a941e0bc5f99f0d8e99cfd1d8ac0d7.tar.bz2
matterbridge-msglm-6ebd5cbbd8a941e0bc5f99f0d8e99cfd1d8ac0d7.zip
Refactor and update RocketChat bridge
* Add support for editing/deleting messages * Add support for uploading files * Add support for avatars * Use the Rocket.Chat.Go.SDK * Use the rest and streaming api
Diffstat (limited to 'vendor/github.com/gopackage/ddp/ddp_messages.go')
-rw-r--r--vendor/github.com/gopackage/ddp/ddp_messages.go82
1 files changed, 82 insertions, 0 deletions
diff --git a/vendor/github.com/gopackage/ddp/ddp_messages.go b/vendor/github.com/gopackage/ddp/ddp_messages.go
new file mode 100644
index 00000000..68c9eab4
--- /dev/null
+++ b/vendor/github.com/gopackage/ddp/ddp_messages.go
@@ -0,0 +1,82 @@
+package ddp
+
+// ------------------------------------------------------------
+// DDP Messages
+//
+// Go structs representing DDP raw messages ready for JSON
+// encoding.
+// ------------------------------------------------------------
+
+// Message contains the common fields that all DDP messages use.
+type Message struct {
+ Type string `json:"msg"`
+ ID string `json:"id,omitempty"`
+}
+
+// Connect represents a DDP connect message.
+type Connect struct {
+ Message
+ Version string `json:"version"`
+ Support []string `json:"support"`
+ Session string `json:"session,omitempty"`
+}
+
+// NewConnect creates a new connect message
+func NewConnect() *Connect {
+ return &Connect{Message: Message{Type: "connect"}, Version: "1", Support: []string{"1"}}
+}
+
+// NewReconnect creates a new connect message with a session ID to resume.
+func NewReconnect(session string) *Connect {
+ c := NewConnect()
+ c.Session = session
+ return c
+}
+
+// Ping represents a DDP ping message.
+type Ping Message
+
+// NewPing creates a new ping message with optional ID.
+func NewPing(id string) *Ping {
+ return &Ping{Type: "ping", ID: id}
+}
+
+// Pong represents a DDP pong message.
+type Pong Message
+
+// NewPong creates a new pong message with optional ID.
+func NewPong(id string) *Pong {
+ return &Pong{Type: "pong", ID: id}
+}
+
+// Method is used to send a remote procedure call to the server.
+type Method struct {
+ Message
+ ServiceMethod string `json:"method"`
+ Args []interface{} `json:"params"`
+}
+
+// NewMethod creates a new method invocation object.
+func NewMethod(id, serviceMethod string, args []interface{}) *Method {
+ return &Method{
+ Message: Message{Type: "method", ID: id},
+ ServiceMethod: serviceMethod,
+ Args: args,
+ }
+}
+
+// Sub is used to send a subscription request to the server.
+type Sub struct {
+ Message
+ SubName string `json:"name"`
+ Args []interface{} `json:"params"`
+}
+
+// NewSub creates a new sub object.
+func NewSub(id, subName string, args []interface{}) *Sub {
+ return &Sub{
+ Message: Message{Type: "sub", ID: id},
+ SubName: subName,
+ Args: args,
+ }
+}