Compare commits

..

2 Commits

Author SHA1 Message Date
Nguyen Minh 2c00022622 fix conflict 2023-03-23 10:36:07 +07:00
Nguyen Minh afd6b215d6 reqrep socket 2023-03-23 10:34:58 +07:00
4 changed files with 46 additions and 0 deletions

21
client/socket.go Normal file
View File

@ -0,0 +1,21 @@
package client
import (
"git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model"
"git.selly.red/Selly-Modules/natsio/subject"
)
// Socket ...
type Socket struct{}
// GetSocket ...
func GetSocket() Socket {
return Socket{}
}
// EmitSocketEventDataReward ...
func (s Socket) EmitSocketEventDataReward(p model.PayloadEmitSocketEvent) error {
_, err := natsio.GetServer().Request(subject.Socket.EmitEventReward, toBytes(p))
return err
}

9
model/socket.go Normal file
View File

@ -0,0 +1,9 @@
package model
// PayloadEmitSocketEvent ...
type PayloadEmitSocketEvent struct {
User string `json:"user"`
Message string `json:"message"`
Data string `json:"data"`
IsNotRemove bool `json:"isNotRemove"`
}

View File

@ -23,6 +23,7 @@ var prefixes = struct {
Affiliate string
Product string
Queue string
Socket string
}{
Communication: "communication",
Order: "order",
@ -46,4 +47,5 @@ var prefixes = struct {
Affiliate: "affiliate",
Product: "product",
Queue: "queue",
Socket: "socket",
}

14
subject/socket.go Normal file
View File

@ -0,0 +1,14 @@
package subject
import "fmt"
func getSocketValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Socket, val)
}
// Socket ...
var Socket = struct {
EmitEventReward string
}{
EmitEventReward: getSocketValue("emit_event_reward"),
}