Fix golint issues
This commit is contained in:
+29
-14
@@ -12,6 +12,14 @@ import (
|
||||
"ipe/subscription"
|
||||
)
|
||||
|
||||
// SubscribeData data for Subscribe event
|
||||
type SubscribeData struct {
|
||||
Channel string `json:"channel"`
|
||||
Auth string `json:"auth,omitempty"`
|
||||
ChannelData string `json:"channel_data,omitempty"`
|
||||
}
|
||||
|
||||
// Subscribe event
|
||||
// {
|
||||
// "event": "pusher:subscribe",
|
||||
// "data": {
|
||||
@@ -20,27 +28,23 @@ import (
|
||||
// "channelData": "extra data"
|
||||
// }
|
||||
// }
|
||||
type SubscribeData struct {
|
||||
Channel string `json:"channel"`
|
||||
Auth string `json:"auth,omitempty"`
|
||||
ChannelData string `json:"channel_data,omitempty"`
|
||||
}
|
||||
|
||||
type Subscribe struct {
|
||||
Event string `json:"event"`
|
||||
Data SubscribeData `json:"data"`
|
||||
}
|
||||
|
||||
// Create a new subscribe event with the specified channel and data
|
||||
// NewSubscribe Create a new subscribe event with the specified channel and data
|
||||
func NewSubscribe(channel, auth, channelData string) Subscribe {
|
||||
data := SubscribeData{Channel: channel, Auth: auth, ChannelData: channelData}
|
||||
return Subscribe{Event: "pusher:subscribe", Data: data}
|
||||
}
|
||||
|
||||
// UnsubscribeData
|
||||
type UnsubscribeData struct {
|
||||
Channel string `json:"channel"`
|
||||
}
|
||||
|
||||
// Unsubscribe event
|
||||
// {
|
||||
// "event": "pusher:unsubscribe",
|
||||
// "data": {
|
||||
@@ -58,6 +62,7 @@ func NewUnsubscribe(channel string) Unsubscribe {
|
||||
return Unsubscribe{Event: "pusher:unsubscribe", Data: data}
|
||||
}
|
||||
|
||||
// SubscriptionSucceeded event
|
||||
// {
|
||||
// "event": "pusher_internal:subscription_succeeded",
|
||||
// "channel": "the channel"
|
||||
@@ -73,8 +78,7 @@ func NewSubscriptionSucceeded(channel, data string) SubscriptionSucceeded {
|
||||
return SubscriptionSucceeded{Event: "pusher_internal:subscription_succeeded", Channel: channel, Data: data}
|
||||
}
|
||||
|
||||
// Data Subscription Succeed
|
||||
|
||||
// SubscriptionSucceededPresenceData Data Subscription Succeed
|
||||
// "{
|
||||
// \"presence\": {
|
||||
// \"ids\": [\"11814b369700141b222a3f3791cec2d9\",\"71dd6a29da2a4833336d2a964becf820\"],
|
||||
@@ -97,6 +101,7 @@ type SubscriptionSucceededPresenceData struct {
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
// NewSubscriptionSucceedPresenceData returns new SubscriptionSucceededPresenceData
|
||||
func NewSubscriptionSucceedPresenceData(subscriptions map[string]*subscription.Subscription) SubscriptionSucceededPresenceData {
|
||||
event := SubscriptionSucceededPresenceData{}
|
||||
|
||||
@@ -123,6 +128,7 @@ func NewSubscriptionSucceedPresenceData(subscriptions map[string]*subscription.S
|
||||
return event
|
||||
}
|
||||
|
||||
// Pong event
|
||||
// {
|
||||
// "event": "pusher:pong",
|
||||
// "data": {}
|
||||
@@ -132,11 +138,12 @@ type Pong struct {
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// Create a new pong event
|
||||
// NewPong Create a new pong event
|
||||
func NewPong() Pong {
|
||||
return Pong{Event: "pusher:pong", Data: "{}"}
|
||||
}
|
||||
|
||||
// Ping event
|
||||
// {
|
||||
// "event": "pusher:ping",
|
||||
// "data": {}
|
||||
@@ -146,11 +153,12 @@ type Ping struct {
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// Create a new ping event
|
||||
// NewPing Create a new ping event
|
||||
func NewPing() Ping {
|
||||
return Ping{Event: "pusher:ping", Data: "{}"}
|
||||
}
|
||||
|
||||
// Error event
|
||||
// {
|
||||
// "event": "pusher:error",
|
||||
// "data": {
|
||||
@@ -163,7 +171,7 @@ type Error struct {
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
// Create a new error event
|
||||
// NewError Create a new error event
|
||||
// Pusher protocol is very strange in some parts
|
||||
// It send null in some errors.
|
||||
func NewError(code int, message string) Error {
|
||||
@@ -183,6 +191,7 @@ func NewError(code int, message string) Error {
|
||||
return Error{Event: "pusher:error", Data: data}
|
||||
}
|
||||
|
||||
// ConnectionEstablished event
|
||||
// {
|
||||
// "event" : "pusher:connection_established",
|
||||
// "data" : {
|
||||
@@ -195,7 +204,7 @@ type ConnectionEstablished struct {
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// Create a new connection established event using the specified socketId
|
||||
// NewConnectionEstablished Create a new connection established event using the specified socketId
|
||||
func NewConnectionEstablished(socketID string) ConnectionEstablished {
|
||||
b, err := json.Marshal(struct {
|
||||
SocketID string `json:"socket_id"`
|
||||
@@ -211,6 +220,7 @@ func NewConnectionEstablished(socketID string) ConnectionEstablished {
|
||||
return ConnectionEstablished{Event: "pusher:connection_established", Data: string(b)}
|
||||
}
|
||||
|
||||
// MemberAdded event
|
||||
// {
|
||||
// "event": "pusher_internal:member_added",
|
||||
// "channel": "presence-example-channel",
|
||||
@@ -222,10 +232,12 @@ type MemberAdded struct {
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// NewMemberAdded creates a new MemberAdded event
|
||||
func NewMemberAdded(channel, data string) MemberAdded {
|
||||
return MemberAdded{Event: "pusher_internal:member_added", Channel: channel, Data: data}
|
||||
}
|
||||
|
||||
// MemberRemoved event
|
||||
// {
|
||||
// "event": "pusher_internal:member_removed",
|
||||
// "channel": "presence-example-channel",
|
||||
@@ -237,6 +249,7 @@ type MemberRemoved struct {
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// NewMemberRemoved returns a new MemberRemoved event
|
||||
func NewMemberRemoved(channel string, userID string) MemberRemoved {
|
||||
data, err := json.Marshal(struct {
|
||||
UserID string `json:"user_id"`
|
||||
@@ -251,6 +264,7 @@ func NewMemberRemoved(channel string, userID string) MemberRemoved {
|
||||
return MemberRemoved{Event: "pusher_internal:member_removed", Channel: channel, Data: string(data)}
|
||||
}
|
||||
|
||||
// Raw event, usually used for client events
|
||||
// {
|
||||
// "event": "client-?",
|
||||
// "channel": "The channel",
|
||||
@@ -262,13 +276,14 @@ type Raw struct {
|
||||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
// Response event
|
||||
type Response struct {
|
||||
Event string `json:"event"`
|
||||
Channel string `json:"channel"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
// The response event that is broadcasted to the client sockets
|
||||
// NewResponse The response event that is broadcasted to the client sockets
|
||||
func NewResponse(name, channel string, data interface{}) Response {
|
||||
return Response{Event: name, Channel: channel, Data: data}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user