|
|
@@ -29,7 +29,7 @@ func ActionNotification(ctx *context.Context) { |
|
|
|
} |
|
|
|
client := &socketwrap.Client{Manager: SocketManager, Conn: conn, Send: make(chan *models.Action, 256)} |
|
|
|
|
|
|
|
WriteLastTenActionsIfHave(conn) |
|
|
|
WriteLastActionsIfHave(conn) |
|
|
|
|
|
|
|
client.Manager.Register <- client |
|
|
|
|
|
|
@@ -37,12 +37,12 @@ func ActionNotification(ctx *context.Context) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func WriteLastTenActionsIfHave(conn *websocket.Conn) { |
|
|
|
socketwrap.LastTenActionsQueue.Mutex.RLock() |
|
|
|
func WriteLastActionsIfHave(conn *websocket.Conn) { |
|
|
|
socketwrap.LastActionsQueue.Mutex.RLock() |
|
|
|
{ |
|
|
|
size := socketwrap.LastTenActionsQueue.Queue.Len() |
|
|
|
size := socketwrap.LastActionsQueue.Queue.Len() |
|
|
|
if size > 0 { |
|
|
|
tempE := socketwrap.LastTenActionsQueue.Queue.Front() |
|
|
|
tempE := socketwrap.LastActionsQueue.Queue.Front() |
|
|
|
conn.WriteJSON(tempE.Value) |
|
|
|
for i := 1; i < size; i++ { |
|
|
|
tempE = tempE.Next() |
|
|
@@ -52,5 +52,5 @@ func WriteLastTenActionsIfHave(conn *websocket.Conn) { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
socketwrap.LastTenActionsQueue.Mutex.RUnlock() |
|
|
|
socketwrap.LastActionsQueue.Mutex.RUnlock() |
|
|
|
} |