Skip to content

AmirRezaM75/kenopsiauser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a Golang package for user service (one of the kenopsia microservices)

It exposes methods which are common when adding new game to the ecosystem.

Install

go get github.com/amirrezam75/kenopsiauser

Usages

package main

import "github.com/amirrezam75/kenopsiauser"

var userRepository = kenopsiauser.NewUserRepository(
	os.Getenv("KENOPSIA_USER_BASE_URL"),
)
var gameService = services.NewGameService(gameRepository, hubRepository, userRepository)

Acquire User Id

Since headers cannot be set in a WebSocket connection, we use a one-time token instead. The client must provide this token before establishing the WebSocket connection, and your game service will need a method to identify which user the token belongs to.

https://devcenter.heroku.com/articles/websocket-security

package services

type GameService struct {
	gameRepository GameRepository
	hubRepository  HubRepository
	userRepository kenopsiauser.UserRepository
}

func (game GameService) Join(gameId, ticketId string, connection *websocket.Conn) {
	userId, err := game.userRepository.AcquireUserId(ticketId)
	if err != nil {
		// Handler error
	}
}

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages