new json_data model
This commit is contained in:
@@ -12,11 +12,13 @@ import (
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
// serves as connection handler of websocket
|
||||
type Connections struct {
|
||||
sync.RWMutex
|
||||
Clients Clients
|
||||
}
|
||||
|
||||
// initaiates new conections with client map
|
||||
func NewConnections() *Connections {
|
||||
return &Connections{
|
||||
Clients: NewClients(),
|
||||
@@ -36,10 +38,11 @@ func (c *Connections) DisconnectWsConnection(id string, code websocket.StatusCod
|
||||
c.Clients.DisconnectWsConnection(id, code, reason)
|
||||
}
|
||||
|
||||
// sends json response to client
|
||||
func (c *Connections) SendResponse(id string, r *json_dataModels.Response) error {
|
||||
client, ok := c.Clients[id]
|
||||
if !ok {
|
||||
return fmt.Errorf("client not found for id " + id)
|
||||
return fmt.Errorf("client not found for id %s", id)
|
||||
|
||||
}
|
||||
b, err := json.Marshal(r)
|
||||
|
Reference in New Issue
Block a user