Added unique id to callbacks so they can be referenced. Since Go doens't actually provide unique function pointers, we use the closest we can get by grabbing the pointer for the function and slapping a random int on the end. Does it guarantee there will never be a collision? No, but it makes it's pretty damn unlikely that you'll get one during the lifetime of an app unless you are generating millions and millions of callbacks and never, ever deleting them, in which case you probably have something else to worry about
This commit is contained in:
@@ -33,7 +33,7 @@ type Connection struct {
|
||||
user string
|
||||
registered bool
|
||||
server string
|
||||
events map[string][]func(*Event)
|
||||
events map[string]map[string]func(*Event)
|
||||
|
||||
lastMessage time.Time
|
||||
|
||||
|
||||
Reference in New Issue
Block a user