Debian Codegraph @

internal/clientproto/protocol.go

raw
1 package clientproto
2
3 import (
4 "github.com/centrifugal/protocol"
5 )
6
7 // NewMessagePush returns initialized async push message.
8 func NewMessagePush(data protocol.Raw) *protocol.Push {
9 return &protocol.Push{
10 Type: protocol.PushTypeMessage,
11 Data: data,
12 }
13 }
14
15 // NewPublicationPush returns initialized async publication message.
16 func NewPublicationPush(ch string, data protocol.Raw) *protocol.Push {
17 return &protocol.Push{
18 Type: protocol.PushTypePublication,
19 Channel: ch,
20 Data: data,
21 }
22 }
23
24 // NewJoinPush returns initialized async join message.
25 func NewJoinPush(ch string, data protocol.Raw) *protocol.Push {
26 return &protocol.Push{
27 Type: protocol.PushTypeJoin,
28 Channel: ch,
29 Data: data,
30 }
31 }
32
33 // NewLeavePush returns initialized async leave message.
34 func NewLeavePush(ch string, data protocol.Raw) *protocol.Push {
35 return &protocol.Push{
36 Type: protocol.PushTypeLeave,
37 Channel: ch,
38 Data: data,
39 }
40 }
41
42 // NewUnsubPush returns initialized async unsubscribe message.
43 func NewUnsubPush(ch string, data protocol.Raw) *protocol.Push {
44 return &protocol.Push{
45 Type: protocol.PushTypeUnsub,
46 Channel: ch,
47 Data: data,
48 }
49 }
50
51 // NewSubPush returns initialized async subscribe message.
52 func NewSubPush(ch string, data protocol.Raw) *protocol.Push {
53 return &protocol.Push{
54 Type: protocol.PushTypeSub,
55 Channel: ch,
56 Data: data,
57 }
58 }