temp upload
This commit is contained in:
parent
d39ff53e09
commit
ab22012eb5
2
def.go
2
def.go
@ -13,7 +13,7 @@ type DataBackup struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MQKeepAlive struct {
|
type MQKeepAlive struct {
|
||||||
UserID64 int64 `json:"user_id"`
|
TGUserID64 int64 `json:"tg_user_id"`
|
||||||
Nickname string `json:"nick"`
|
Nickname string `json:"nick"`
|
||||||
Queue string `json:"queue"`
|
Queue string `json:"queue"`
|
||||||
Date time.Time `json:"date"`
|
Date time.Time `json:"date"`
|
||||||
|
3
items.go
3
items.go
@ -108,7 +108,10 @@ func resetObjItem() {
|
|||||||
reloadObjItem(`513`, `Silver Arrow`, objSubTypeItemMisc, 10)
|
reloadObjItem(`513`, `Silver Arrow`, objSubTypeItemMisc, 10)
|
||||||
reloadObjItem(`515`, `Broad Arrows Pack`, objSubTypeItemMisc, -1)
|
reloadObjItem(`515`, `Broad Arrows Pack`, objSubTypeItemMisc, -1)
|
||||||
reloadObjItem(`517`, `Heavy Arrows Pack`, objSubTypeItemMisc, -1)
|
reloadObjItem(`517`, `Heavy Arrows Pack`, objSubTypeItemMisc, -1)
|
||||||
|
reloadObjItem(`518`, `Hay`, objSubTypeItemResource, -1)
|
||||||
reloadObjItem(`519`, `Compound Arrows Pack`, objSubTypeItemMisc, -1)
|
reloadObjItem(`519`, `Compound Arrows Pack`, objSubTypeItemMisc, -1)
|
||||||
|
reloadObjItem(`520`, `Hamsters`, objSubTypeItemResource, -1)
|
||||||
|
reloadObjItem(`521`, `Cheese`, objSubTypeItemResource, -1)
|
||||||
reloadObjItem(`614`, `🎟Gift Coupon 'Pig'`, objSubTypeItemMisc, 1)
|
reloadObjItem(`614`, `🎟Gift Coupon 'Pig'`, objSubTypeItemMisc, 1)
|
||||||
reloadObjItem(`615`, `🎟Gift Coupon 'Horse'`, objSubTypeItemMisc, 1)
|
reloadObjItem(`615`, `🎟Gift Coupon 'Horse'`, objSubTypeItemMisc, 1)
|
||||||
reloadObjItem(`616`, `🎟Gift Coupon 'Owl'`, objSubTypeItemMisc, 1)
|
reloadObjItem(`616`, `🎟Gift Coupon 'Owl'`, objSubTypeItemMisc, 1)
|
||||||
|
3
main.go
3
main.go
@ -51,7 +51,7 @@ var (
|
|||||||
cfg Config
|
cfg Config
|
||||||
|
|
||||||
RndSrc *rand.Rand
|
RndSrc *rand.Rand
|
||||||
RndMu sync.Mutex
|
RndMux sync.Mutex
|
||||||
|
|
||||||
MQCWMsgQueue chan ChatWarsMessage
|
MQCWMsgQueue chan ChatWarsMessage
|
||||||
SQLMsgIdentifyQueue chan int64
|
SQLMsgIdentifyQueue chan int64
|
||||||
@ -64,6 +64,7 @@ var (
|
|||||||
|
|
||||||
clientsCW *sync.Map
|
clientsCW *sync.Map
|
||||||
clientsKeepAlive *sync.Map
|
clientsKeepAlive *sync.Map
|
||||||
|
muxKeepAlive sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
func PrintText(m *tb.Message) {
|
func PrintText(m *tb.Message) {
|
||||||
|
12
workers.go
12
workers.go
@ -109,7 +109,6 @@ func MQKeepAliveWorker() {
|
|||||||
c.Connection, err = amqp.Dial("amqp://" + c.User + ":" + c.Password + "@" + c.Host + "/" + c.Path)
|
c.Connection, err = amqp.Dial("amqp://" + c.User + ":" + c.Password + "@" + c.Host + "/" + c.Path)
|
||||||
logOnError(err, "MQKeepAliveWorker : Cannot open MQ connection")
|
logOnError(err, "MQKeepAliveWorker : Cannot open MQ connection")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Connection.Close()
|
|
||||||
time.Sleep(15 * time.Second)
|
time.Sleep(15 * time.Second)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -162,9 +161,10 @@ func MQKeepAliveWorker() {
|
|||||||
err = json.Unmarshal(d.Body, &x)
|
err = json.Unmarshal(d.Body, &x)
|
||||||
logOnError(err, "MQKeepAliveWorker : Can't unmarshal.\n"+string(d.Body))
|
logOnError(err, "MQKeepAliveWorker : Can't unmarshal.\n"+string(d.Body))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
muxKeepAlive.Lock()
|
||||||
if x.Date.Add(10 * time.Second).Before(time.Now()) {
|
if x.Date.Add(10 * time.Second).Before(time.Now()) {
|
||||||
// outdated keep-alive coming from client
|
// outdated keep-alive coming from client
|
||||||
} else if v, ok := clientsKeepAlive.Load(x.UserID64); ok {
|
} else if v, ok := clientsKeepAlive.Load(x.TGUserID64); ok {
|
||||||
k := v.(*MQKeepAlive)
|
k := v.(*MQKeepAlive)
|
||||||
k.Date = x.Date
|
k.Date = x.Date
|
||||||
} else {
|
} else {
|
||||||
@ -201,12 +201,12 @@ func MQKeepAliveWorker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clientsKeepAlive.Store(x.UserID64, &x)
|
clientsKeepAlive.Store(x.TGUserID64, &x)
|
||||||
clientsQueue[x.UserID64] = &clt
|
clientsQueue[x.TGUserID64] = &clt
|
||||||
|
|
||||||
c := TGCommand{
|
c := TGCommand{
|
||||||
Type: commandSendMsg,
|
Type: commandSendMsg,
|
||||||
ToUserID64: x.UserID64,
|
ToUserID64: x.TGUserID64,
|
||||||
Text: "Your client is connected.",
|
Text: "Your client is connected.",
|
||||||
}
|
}
|
||||||
TGCmdQueue <- c
|
TGCmdQueue <- c
|
||||||
@ -219,7 +219,7 @@ func MQKeepAliveWorker() {
|
|||||||
|
|
||||||
clientSendCWMsg(x.UserID64, `🏅Me`)
|
clientSendCWMsg(x.UserID64, `🏅Me`)
|
||||||
}
|
}
|
||||||
|
muxKeepAlive.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.Channel.Close()
|
c.Channel.Close()
|
||||||
|
Loading…
Reference in New Issue
Block a user