Last active
December 22, 2021 14:41
-
-
Save Jimeux/86b8b82deea446448faad46126db790e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WebSocketService implements the core logic of svc-ws. | |
type WebSocketService struct { | |
client *Client | |
repository *Repository | |
} | |
func NewWebSocketService(client *Client, repository *Repository) *WebSocketService { | |
return &WebSocketService{ | |
client: client, | |
repository: repository, | |
} | |
} | |
// Connect saves a reference to connID in the datastore. | |
func (s *WebSocketService) Connect(ctx context.Context, connID string) (Response, error) { | |
// save connection initially without username | |
if err := s.repository.SaveConnection(ctx, connID, ""); err != nil { | |
return ResponseInternalServerError(), fmt.Errorf("failed to connect connectionID %s: %w", connID, err) | |
} | |
return ResponseOK(), nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment