7
7
"log"
8
8
"net/http"
9
9
"os"
10
- "sync"
11
10
"strconv"
11
+ "sync"
12
12
13
13
"github.com/gin-gonic/gin"
14
14
"github.com/gorilla/websocket"
@@ -144,9 +144,9 @@ func (h *Hub) Run() {
144
144
145
145
// ServeWs handles WebSocket requests
146
146
func serveWs (
147
- hub * Hub , c * gin.Context ,
148
- roomMappings * verify.RoomMappings ,
149
- persistMappings * verify.PersistMappings ,
147
+ hub * Hub , c * gin.Context ,
148
+ roomMappings * verify.RoomMappings ,
149
+ persistMappings * verify.PersistMappings ,
150
150
) {
151
151
log .Println ("handler called!" )
152
152
roomID := c .Query ("roomID" )
@@ -168,9 +168,9 @@ func serveWs(
168
168
}
169
169
170
170
func authenticateClient (
171
- token string , match string , client * Client ,
172
- roomMappings * verify.RoomMappings ,
173
- persistMappings * verify.PersistMappings ,
171
+ token string , match string , client * Client ,
172
+ roomMappings * verify.RoomMappings ,
173
+ persistMappings * verify.PersistMappings ,
174
174
) bool {
175
175
ok , userID := verifyToken (token )
176
176
if ! ok {
@@ -197,7 +197,8 @@ func handleMessages(
197
197
client * Client , hub * Hub ,
198
198
roomMappings * verify.RoomMappings ,
199
199
persistMappings * verify.PersistMappings ,
200
- ) { defer func () {
200
+ ) {
201
+ defer func () {
201
202
hub .unregister <- client
202
203
}()
203
204
@@ -274,11 +275,11 @@ func statusHandler(hub *Hub) gin.HandlerFunc {
274
275
for client := range hub .clients {
275
276
roomID := client .roomID
276
277
currentStatus , ok := status [roomID ]
277
- if ( ! ok ) {
278
+ if ! ok {
278
279
// Initialize status for a new roomID
279
280
status [roomID ] = map [string ]interface {}{
280
- "clients" : 1 ,
281
- "workspace" : hub .workspaces [roomID ],
281
+ "clients" : 1 ,
282
+ "workspace" : hub .workspaces [roomID ],
282
283
}
283
284
} else {
284
285
// Update the client count for an existing roomID
@@ -324,8 +325,8 @@ func main() {
324
325
}
325
326
}
326
327
327
- roomMappings := verify .InitialiseRoomMappings (REDIS_URI , REDIS_ROOM_MAPPING )
328
- persistMappings := verify .InitialisePersistMappings (REDIS_URI , REDIS_ROOM_PERSIST );
328
+ roomMappings := verify .InitialiseRoomMappings (REDIS_URI , REDIS_ROOM_MAPPING )
329
+ persistMappings := verify .InitialisePersistMappings (REDIS_URI , REDIS_ROOM_PERSIST )
329
330
330
331
// WebSocket connection endpoint
331
332
r .GET ("/ws" , func (c * gin.Context ) {
0 commit comments