Fix lint suggestions

This commit is contained in:
claudemiro
2016-01-16 21:20:23 -02:00
parent cad813e729
commit 3fc072373a
9 changed files with 25 additions and 25 deletions
+2 -2
View File
@@ -58,7 +58,7 @@ func (c *channel) TotalUsers() int {
total := make(map[string]int) total := make(map[string]int)
for _, s := range c.Subscriptions { for _, s := range c.Subscriptions {
total[s.Id]++ total[s.ID]++
} }
return len(total) return len(total)
@@ -96,7 +96,7 @@ func (c *channel) Subscribe(a *app, conn *connection, channelData string) error
} }
// Update the Subscription // Update the Subscription
subscription.Id = info.UserID subscription.ID = info.UserID
subscription.Data = string(js) subscription.Data = string(js)
// Publish pusher_internal:member_added // Publish pusher_internal:member_added
+6 -6
View File
@@ -106,8 +106,8 @@ func newSubscriptionSucceedEventPresenceData(c *channel) subscriptionSucceeedEve
var js interface{} var js interface{}
json.Unmarshal([]byte(s.Data), &js) json.Unmarshal([]byte(s.Data), &js)
hash[s.Id] = js hash[s.ID] = js
ids = append(ids, s.Id) ids = append(ids, s.ID)
} }
event.Ids = ids event.Ids = ids
@@ -193,7 +193,7 @@ func newErrorEvent(code int, message string) errorEvent {
// } // }
// } // }
type connectionEstablishedEventData struct { type connectionEstablishedEventData struct {
SocketId string `json:"socket_id"` SocketID string `json:"socket_id"`
ActivityTimeout int `json:"activity_timeout"` ActivityTimeout int `json:"activity_timeout"`
} }
@@ -203,8 +203,8 @@ type connectionEstablishedEvent struct {
} }
// Create a new connection established event using the specified socketId // Create a new connection established event using the specified socketId
func newConnectionEstablishedEvent(socketId string) connectionEstablishedEvent { func newConnectionEstablishedEvent(socketID string) connectionEstablishedEvent {
data := connectionEstablishedEventData{SocketId: socketId, ActivityTimeout: 120} data := connectionEstablishedEventData{SocketID: socketID, ActivityTimeout: 120}
b, err := json.Marshal(data) b, err := json.Marshal(data)
@@ -245,7 +245,7 @@ func newMemberRemovedEvent(channel string, s *subscription) memberRemovedEvent {
data, err := json.Marshal(struct { data, err := json.Marshal(struct {
UserID string `json:"user_id"` UserID string `json:"user_id"`
}{ }{
UserID: s.Id, UserID: s.ID,
}) })
if err != nil { if err != nil {
+2 -2
View File
@@ -300,8 +300,8 @@ func getChannelUsers(w http.ResponseWriter, r *http.Request) {
for _, s := range channel.Subscriptions { for _, s := range channel.Subscriptions {
users = append(users, struct { users = append(users, struct {
Id string `json:"id"` ID string `json:"id"`
}{s.Id}) }{s.ID})
} }
result["users"] = users result["users"] = users
-1
View File
@@ -5,7 +5,6 @@
package ipe package ipe
import ( import (
_ "expvar"
"net/http" "net/http"
"github.com/gorilla/mux" "github.com/gorilla/mux"
+5 -5
View File
@@ -18,35 +18,35 @@ type route struct {
} }
var routes = []route{ var routes = []route{
route{ {
"PostEvents", "PostEvents",
"POST", "POST",
"/apps/{app_id}/events", "/apps/{app_id}/events",
postEvents, postEvents,
true, true,
}, },
route{ {
"GetChannels", "GetChannels",
"GET", "GET",
"/apps/{app_id}/channels", "/apps/{app_id}/channels",
getChannels, getChannels,
true, true,
}, },
route{ {
"GetChannel", "GetChannel",
"GET", "GET",
"/apps/{app_id}/channels/{channel_name}", "/apps/{app_id}/channels/{channel_name}",
getChannel, getChannel,
true, true,
}, },
route{ {
"GetChannelUsers", "GetChannelUsers",
"GET", "GET",
"/apps/{app_id}/channels/{channel_name}/users", "/apps/{app_id}/channels/{channel_name}/users",
getChannelUsers, getChannelUsers,
true, true,
}, },
route{ {
"Websocket", "Websocket",
"GET", "GET",
"/app/{key}", "/app/{key}",
+1 -1
View File
@@ -7,7 +7,7 @@ package ipe
// A Channel Subscription // A Channel Subscription
type subscription struct { type subscription struct {
Connection *connection Connection *connection
Id string ID string
Data string Data string
} }
+6 -6
View File
@@ -44,7 +44,7 @@ type hookEvent struct {
Event string `json:"event,omitempty"` Event string `json:"event,omitempty"`
Data interface{} `json:"data,omitempty"` Data interface{} `json:"data,omitempty"`
SocketID string `json:"socket_id,omitempty"` SocketID string `json:"socket_id,omitempty"`
UserId string `json:"user_id,omitempty"` UserID string `json:"user_id,omitempty"`
} }
func newChannelOcuppiedHook(channel *channel) hookEvent { func newChannelOcuppiedHook(channel *channel) hookEvent {
@@ -56,11 +56,11 @@ func newChannelVacatedHook(channel *channel) hookEvent {
} }
func newMemberAddedHook(channel *channel, s *subscription) hookEvent { func newMemberAddedHook(channel *channel, s *subscription) hookEvent {
return hookEvent{Name: "member_added", Channel: channel.ChannelID, UserId: s.Id} return hookEvent{Name: "member_added", Channel: channel.ChannelID, UserID: s.ID}
} }
func newMemberRemovedHook(channel *channel, s *subscription) hookEvent { func newMemberRemovedHook(channel *channel, s *subscription) hookEvent {
return hookEvent{Name: "member_removed", Channel: channel.ChannelID, UserId: s.Id} return hookEvent{Name: "member_removed", Channel: channel.ChannelID, UserID: s.ID}
} }
func newClientHook(channel *channel, s *subscription, event string, data interface{}) hookEvent { func newClientHook(channel *channel, s *subscription, event string, data interface{}) hookEvent {
@@ -89,11 +89,11 @@ func (a *app) TriggerChannelVacatedHook(c *channel) {
// "socket_id": "socket_id of the sending socket", // "socket_id": "socket_id of the sending socket",
// "user_id": "user_id associated with the sending socket" # Only for presence channels // "user_id": "user_id associated with the sending socket" # Only for presence channels
// } // }
func (a *app) TriggerClientEventHook(c *channel, s *subscription, client_event string, data interface{}) { func (a *app) TriggerClientEventHook(c *channel, s *subscription, clientEvent string, data interface{}) {
event := newClientHook(c, s, client_event, data) event := newClientHook(c, s, clientEvent, data)
if c.IsPresence() { if c.IsPresence() {
event.UserId = s.Id event.UserID = s.ID
} }
triggerHook(event.Name, a, c, event) triggerHook(event.Name, a, c, event)
+1 -1
View File
@@ -24,7 +24,7 @@ func main() {
} }
} }
// Print a beatifull banner // Print a beautifull banner
func printBanner() { func printBanner() {
fmt.Print("\033[36m") fmt.Print("\033[36m")
fmt.Print(` fmt.Print(`
+2 -1
View File
@@ -23,7 +23,7 @@ func HashMAC(message, key []byte) string {
return hex.EncodeToString(expected) return hex.EncodeToString(expected)
} }
// Generate a new random Hash // GenerateSessionID Generate a new random Hash
func GenerateSessionID() string { func GenerateSessionID() string {
MAX := 999999999 MAX := 999999999
rand.Seed(time.Now().Unix()) rand.Seed(time.Now().Unix())
@@ -31,6 +31,7 @@ func GenerateSessionID() string {
return fmt.Sprintf("%d.%d", rand.Intn(MAX), rand.Intn(MAX)) return fmt.Sprintf("%d.%d", rand.Intn(MAX), rand.Intn(MAX))
} }
// IsChannelNameValid Verify if the channel name is valid
func IsChannelNameValid(channelName string) bool { func IsChannelNameValid(channelName string) bool {
matched, err := regexp.MatchString("^[A-Za-z0-9_\\-=@,.;]+$", channelName) matched, err := regexp.MatchString("^[A-Za-z0-9_\\-=@,.;]+$", channelName)