MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / LogOutUserByConnectionId

Function LogOutUserByConnectionId

internal/users/users.go:375–401  ·  view source on GitHub ↗
(connectionId connections.ConnectionId)

Source from the content-addressed store, hash-verified

373}
374
375func LogOutUserByConnectionId(connectionId connections.ConnectionId) error {
376
377 u := GetByConnectionId(connectionId)
378
379 userManagerMu.Lock()
380 defer userManagerMu.Unlock()
381
382 if _, ok := userManager.Connections[connectionId]; ok {
383
384 // Make sure the user data is saved to a file.
385 if u != nil {
386 u.Character.Validate()
387 SaveUser(*u)
388
389 delete(userManager.Users, u.UserId)
390 delete(userManager.Usernames, u.Username)
391 delete(userManager.Connections, u.connectionId)
392 delete(userManager.UserConnections, u.UserId)
393 } else {
394 // Connection exists but user record is missing - clean up the connection entry
395 delete(userManager.Connections, connectionId)
396 }
397
398 return nil
399 }
400 return errors.New("user not found for connection")
401}
402
403// First time creating a user.
404func CreateUser(u *UserRecord) error {

Calls 7

GetByConnectionIdFunction · 0.85
SaveUserFunction · 0.85
deleteFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
NewMethod · 0.80
ValidateMethod · 0.65