Add an Ad-Hoc command to force Steam deconnexion
This commit is contained in:
parent
43d9c6c5c6
commit
3e3347123f
|
|
@ -31,3 +31,8 @@ func (g *GatewayInfo) Run() {
|
|||
func (g *GatewayInfo) SetSteamAuthCode(authCode string) {
|
||||
g.SteamLoginInfo.AuthCode = authCode
|
||||
}
|
||||
|
||||
func (g *GatewayInfo) Disconnect() {
|
||||
g.XMPP_Disconnect()
|
||||
go g.SteamDisconnect()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,11 +67,9 @@ func (g *GatewayInfo) ReceivedXMPP_Presence(presence *xmpp.Presence) {
|
|||
if presence.Type == Type_unavailable {
|
||||
// Disconnect
|
||||
if len(g.XMPP_Connected_Client) <= 0 {
|
||||
g.XMPP_Disconnect()
|
||||
go g.SteamDisconnect()
|
||||
g.Disconnect()
|
||||
}
|
||||
} else if presence.Type == Type_available {
|
||||
g.XMPP_Connect()
|
||||
go g.SteamConnect()
|
||||
transfertPresence = true
|
||||
}
|
||||
|
|
@ -81,11 +79,9 @@ func (g *GatewayInfo) ReceivedXMPP_Presence(presence *xmpp.Presence) {
|
|||
if presence.Type == Type_unavailable {
|
||||
// Disconnect
|
||||
if len(g.XMPP_Connected_Client) <= 0 {
|
||||
g.XMPP_Disconnect()
|
||||
go g.SteamDisconnect()
|
||||
g.Disconnect()
|
||||
}
|
||||
} else if presence.Type == Type_available {
|
||||
g.XMPP_Connect()
|
||||
go g.SteamConnect()
|
||||
transfertPresence = true
|
||||
}
|
||||
|
|
@ -124,12 +120,7 @@ func (g *GatewayInfo) ReceivedXMPP_Message(message *xmpp.Message) {
|
|||
g.SendSteamMessage(steamID, message.Subject+"\n"+message.Body)
|
||||
}
|
||||
|
||||
func (g *GatewayInfo) XMPP_Connect() {
|
||||
// TODO multi client connected management
|
||||
}
|
||||
|
||||
func (g *GatewayInfo) XMPP_Disconnect() {
|
||||
// TODO multi client connected management
|
||||
g.SendXmppPresence(Status_offline, Type_unavailable, "", "", "")
|
||||
}
|
||||
|
||||
|
|
|
|||
2
main.go
2
main.go
|
|
@ -15,7 +15,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
Version = "v0.3.5"
|
||||
Version = "v0.3.6"
|
||||
configurationFilePath = "xmpp4steam.cfg"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
const (
|
||||
CommandAuthcode = "steamAuthCodeCommand"
|
||||
CommandGetIdentifiants = "steamGetIdentifiants"
|
||||
CommandDisconnectSteam = "disconnectSteam"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -27,6 +28,8 @@ func execDiscoCommand(iq *xmpp.Iq) {
|
|||
discoItem.Item = append(discoItem.Item, *discoI)
|
||||
discoI = &xmpp.DiscoItem{JID: jid.Domain, Node: CommandGetIdentifiants, Name: "Steam registration"}
|
||||
discoItem.Item = append(discoItem.Item, *discoI)
|
||||
discoI = &xmpp.DiscoItem{JID: jid.Domain, Node: CommandDisconnectSteam, Name: "Force Steam deconnexion"}
|
||||
discoItem.Item = append(discoItem.Item, *discoI)
|
||||
|
||||
reply.PayloadEncode(discoItem)
|
||||
comp.Out <- reply
|
||||
|
|
@ -62,6 +65,21 @@ func execCommandAdHoc(iq *xmpp.Iq) {
|
|||
|
||||
cmd.XForm = *cmdXForm
|
||||
cmd.Note = *note
|
||||
} else if adHoc.Node == CommandDisconnectSteam {
|
||||
cmd.Status = xmpp.StatusAdHocCompleted
|
||||
cmdXForm := &xmpp.AdHocXForm{Type: xmpp.TypeAdHocResult, Title: "Force Steam deconnexion"}
|
||||
cmd.XForm = *cmdXForm
|
||||
note := &xmpp.AdHocNote{Type: xmpp.TypeAdHocNoteInfo}
|
||||
|
||||
jidBare := strings.SplitN(iq.From, "/", 2)[0]
|
||||
g := MapGatewayInfo[jidBare]
|
||||
if g != nil {
|
||||
g.Disconnect()
|
||||
note.Value = "Send deconnexion on Steam network"
|
||||
} else {
|
||||
note.Value = "Your are not registred."
|
||||
}
|
||||
cmd.Note = *note
|
||||
}
|
||||
reply.PayloadEncode(cmd)
|
||||
comp.Out <- reply
|
||||
|
|
|
|||
|
|
@ -167,7 +167,6 @@ func SendMessage(to, subject, message string) {
|
|||
func AddNewUser(jid, steamLogin, steamPwd string) {
|
||||
log.Printf("%sAdd user %s to the map", LogInfo, jid)
|
||||
|
||||
// TODO Move Gateway creation into right package
|
||||
g := new(gateway.GatewayInfo)
|
||||
g.SteamLogin = steamLogin
|
||||
g.SteamPassword = steamPwd
|
||||
|
|
|
|||
Loading…
Reference in New Issue