diff options
author | Chris <ccbrown112@gmail.com> | 2017-10-03 10:53:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-03 10:53:53 -0500 |
commit | 5e69ce099f521aa49fc267c62235c003eae530ff (patch) | |
tree | c7177e4cac419082753225819f62d07c8b5671e8 /app/status.go | |
parent | bfe7955fb0c72bb6f3e0a1e0aaca70cff27d7ddc (diff) | |
download | chat-5e69ce099f521aa49fc267c62235c003eae530ff.tar.gz chat-5e69ce099f521aa49fc267c62235c003eae530ff.tar.bz2 chat-5e69ce099f521aa49fc267c62235c003eae530ff.zip |
Goroutine wranglin (#7556)
* goroutine wranglin
* synchronize WebConn.WritePump
Diffstat (limited to 'app/status.go')
-rw-r--r-- | app/status.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/status.go b/app/status.go index edfda561b..3d4837cb0 100644 --- a/app/status.go +++ b/app/status.go @@ -221,7 +221,9 @@ func (a *App) BroadcastStatus(status *model.Status) { event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_STATUS_CHANGE, "", "", status.UserId, nil) event.Add("status", status.Status) event.Add("user_id", status.UserId) - go a.Publish(event) + a.Go(func() { + a.Publish(event) + }) } func (a *App) SetStatusOffline(userId string, manual bool) { @@ -245,7 +247,9 @@ func (a *App) SetStatusOffline(userId string, manual bool) { event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_STATUS_CHANGE, "", "", status.UserId, nil) event.Add("status", model.STATUS_OFFLINE) event.Add("user_id", status.UserId) - go a.Publish(event) + a.Go(func() { + a.Publish(event) + }) } func (a *App) SetStatusAwayIfNeeded(userId string, manual bool) { @@ -286,7 +290,9 @@ func (a *App) SetStatusAwayIfNeeded(userId string, manual bool) { event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_STATUS_CHANGE, "", "", status.UserId, nil) event.Add("status", model.STATUS_AWAY) event.Add("user_id", status.UserId) - go a.Publish(event) + a.Go(func() { + a.Publish(event) + }) } func GetStatusFromCache(userId string) *model.Status { |