Compare commits
No commits in common. "0b04382ca0aee5e7db18f8c02e539c379a0929d5" and "6d1fcc1333eec91c01adb66c51858439e3662938" have entirely different histories.
0b04382ca0
...
6d1fcc1333
|
|
@ -25,7 +25,6 @@ type GatewayInfo struct {
|
||||||
// XMPP
|
// XMPP
|
||||||
XMPP_JID_Client string
|
XMPP_JID_Client string
|
||||||
XMPP_Out chan interface{}
|
XMPP_Out chan interface{}
|
||||||
XMPP_Connected_Client map[string]bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GatewayInfo) Run() {
|
func (g *GatewayInfo) Run() {
|
||||||
|
|
|
||||||
|
|
@ -45,16 +45,6 @@ func (g *GatewayInfo) ReceivedXMPP_Presence(presence *xmpp.Presence) {
|
||||||
|
|
||||||
transfertPresence := false
|
transfertPresence := false
|
||||||
|
|
||||||
jid := strings.SplitN(presence.From, "/", 2)
|
|
||||||
if len(jid) == 2 {
|
|
||||||
// Resource exist —> client speaking
|
|
||||||
if presence.Type == Type_available {
|
|
||||||
g.XMPP_Connected_Client[presence.From] = true
|
|
||||||
} else if presence.Type == Type_unavailable {
|
|
||||||
delete(g.XMPP_Connected_Client, presence.From)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if presence.Type == Type_subscribe {
|
if presence.Type == Type_subscribe {
|
||||||
// Send presence to tell that the JID has been added to roster
|
// Send presence to tell that the JID has been added to roster
|
||||||
g.SendXmppPresence("", Type_subscribed, presence.To, g.XMPP_JID_Client, "")
|
g.SendXmppPresence("", Type_subscribed, presence.To, g.XMPP_JID_Client, "")
|
||||||
|
|
@ -66,12 +56,11 @@ func (g *GatewayInfo) ReceivedXMPP_Presence(presence *xmpp.Presence) {
|
||||||
// Destination is gateway itself
|
// Destination is gateway itself
|
||||||
if presence.Type == Type_unavailable {
|
if presence.Type == Type_unavailable {
|
||||||
// Disconnect
|
// Disconnect
|
||||||
if len(g.XMPP_Connected_Client) <= 0 {
|
// TODO multi client connected management
|
||||||
g.XMPP_Disconnect()
|
g.XMPP_Disconnect()
|
||||||
go g.SteamDisconnect()
|
go g.SteamDisconnect()
|
||||||
}
|
|
||||||
} else if presence.Type == Type_available {
|
} else if presence.Type == Type_available {
|
||||||
g.XMPP_Connect()
|
// TODO multi client connected management
|
||||||
go g.SteamConnect()
|
go g.SteamConnect()
|
||||||
transfertPresence = true
|
transfertPresence = true
|
||||||
}
|
}
|
||||||
|
|
@ -80,12 +69,11 @@ func (g *GatewayInfo) ReceivedXMPP_Presence(presence *xmpp.Presence) {
|
||||||
// Destination is Steam user
|
// Destination is Steam user
|
||||||
if presence.Type == Type_unavailable {
|
if presence.Type == Type_unavailable {
|
||||||
// Disconnect
|
// Disconnect
|
||||||
if len(g.XMPP_Connected_Client) <= 0 {
|
// TODO multi client connected management
|
||||||
g.XMPP_Disconnect()
|
g.XMPP_Disconnect()
|
||||||
go g.SteamDisconnect()
|
go g.SteamDisconnect()
|
||||||
}
|
|
||||||
} else if presence.Type == Type_available {
|
} else if presence.Type == Type_available {
|
||||||
g.XMPP_Connect()
|
// TODO multi client connected management
|
||||||
go g.SteamConnect()
|
go g.SteamConnect()
|
||||||
transfertPresence = true
|
transfertPresence = true
|
||||||
}
|
}
|
||||||
|
|
@ -124,12 +112,7 @@ func (g *GatewayInfo) ReceivedXMPP_Message(message *xmpp.Message) {
|
||||||
g.SendSteamMessage(steamID, message.Subject+"\n"+message.Body)
|
g.SendSteamMessage(steamID, message.Subject+"\n"+message.Body)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GatewayInfo) XMPP_Connect() {
|
|
||||||
// TODO multi client connected management
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GatewayInfo) XMPP_Disconnect() {
|
func (g *GatewayInfo) XMPP_Disconnect() {
|
||||||
// TODO multi client connected management
|
|
||||||
g.SendXmppPresence(Status_offline, Type_unavailable, "", "", "")
|
g.SendXmppPresence(Status_offline, Type_unavailable, "", "", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -15,7 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "go-xmpp4steam v0.3.4"
|
Version = "go-xmpp4steam v0.3.2"
|
||||||
configurationFilePath = "xmpp4steam.cfg"
|
configurationFilePath = "xmpp4steam.cfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ func execCommandAdHoc(iq *xmpp.Iq) {
|
||||||
// Command Auth Code
|
// Command Auth Code
|
||||||
cmdXForm := &xmpp.AdHocXForm{Type: xmpp.TypeAdHocForm, Title: "Steam Account Info", Instructions: "Please provide your Steam login and password."}
|
cmdXForm := &xmpp.AdHocXForm{Type: xmpp.TypeAdHocForm, Title: "Steam Account Info", Instructions: "Please provide your Steam login and password."}
|
||||||
// TODO Warn that the given info is stored in database in clear
|
// TODO Warn that the given info is stored in database in clear
|
||||||
note := &xmpp.AdHocNote{Type: xmpp.TypeAdHocNoteInfo, Value: "Please, be aware that the given Steam account information will be saved into an un-encrypted SQLite database."}
|
|
||||||
|
|
||||||
field := &xmpp.AdHocField{Var: "login", Label: "Steam Login", Type: xmpp.TypeAdHocFieldTextSingle}
|
field := &xmpp.AdHocField{Var: "login", Label: "Steam Login", Type: xmpp.TypeAdHocFieldTextSingle}
|
||||||
cmdXForm.Fields = append(cmdXForm.Fields, *field)
|
cmdXForm.Fields = append(cmdXForm.Fields, *field)
|
||||||
|
|
@ -62,7 +61,6 @@ func execCommandAdHoc(iq *xmpp.Iq) {
|
||||||
cmdXForm.Fields = append(cmdXForm.Fields, *field)
|
cmdXForm.Fields = append(cmdXForm.Fields, *field)
|
||||||
|
|
||||||
cmd.XForm = *cmdXForm
|
cmd.XForm = *cmdXForm
|
||||||
cmd.Note = *note
|
|
||||||
}
|
}
|
||||||
reply.PayloadEncode(cmd)
|
reply.PayloadEncode(cmd)
|
||||||
comp.Out <- reply
|
comp.Out <- reply
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,7 @@ func Run() {
|
||||||
comp = must(xmpp.NewComponentXMPP(stream, jid, Secret)).(*xmpp.XMPP)
|
comp = must(xmpp.NewComponentXMPP(stream, jid, Secret)).(*xmpp.XMPP)
|
||||||
|
|
||||||
mainXMPP()
|
mainXMPP()
|
||||||
log.Printf("%sReach main method's end", LogInfo)
|
ChanAction <- ActionMainMethodEnded
|
||||||
go Run()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func mainXMPP() {
|
func mainXMPP() {
|
||||||
|
|
@ -158,7 +157,6 @@ func AddNewUser(jid, steamLogin, steamPwd string) {
|
||||||
g.FriendSteamId = make(map[string]struct{})
|
g.FriendSteamId = make(map[string]struct{})
|
||||||
|
|
||||||
g.XMPP_Out = comp.Out
|
g.XMPP_Out = comp.Out
|
||||||
g.XMPP_Connected_Client = make(map[string]bool)
|
|
||||||
|
|
||||||
MapGatewayInfo[jid] = g
|
MapGatewayInfo[jid] = g
|
||||||
go g.Run()
|
go g.Run()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue