Skip to content

Commit

Permalink
Merge pull request #55 from philippseith/feature/Add_HubContext.Context
Browse files Browse the repository at this point in the history
new: Hub.Context / HubContext.Context
  • Loading branch information
philippseith authored Aug 30, 2021
2 parents 652a4bd + 18b1170 commit 87ae82d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hub.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package signalr

import "sync"
import (
"context"
"sync"
)

// HubInterface is a hubs interface
type HubInterface interface {
Expand Down Expand Up @@ -42,6 +45,11 @@ func (h *Hub) ConnectionID() string {
return h.context.ConnectionID()
}

// Context is the context.Context of the current connection
func (h *Hub) Context() context.Context {
return h.context.Context()
}

// Abort aborts the current connection
func (h *Hub) Abort() {
h.context.Abort()
Expand Down
5 changes: 5 additions & 0 deletions hubcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type HubContext interface {
Groups() GroupManager
Items() *sync.Map
ConnectionID() string
Context() context.Context
Abort()
Logger() (info StructuredLogger, dbg StructuredLogger)
}
Expand Down Expand Up @@ -46,6 +47,10 @@ func (c *connectionHubContext) ConnectionID() string {
return c.connection.ConnectionID()
}

func (c *connectionHubContext) Context() context.Context {
return c.connection.Context()
}

func (c *connectionHubContext) Abort() {
c.abort()
}
Expand Down

0 comments on commit 87ae82d

Please sign in to comment.