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