Compare commits
No commits in common. "0b04382ca0aee5e7db18f8c02e539c379a0929d5" and "6d1fcc1333eec91c01adb66c51858439e3662938" have entirely different histories.
0b04382ca0
...
6d1fcc1333
|
|
@ -23,9 +23,8 @@ type GatewayInfo struct {
|
|||
SteamConnecting bool
|
||||
|
||||
// XMPP
|
||||
XMPP_JID_Client string
|
||||
XMPP_Out chan interface{}
|
||||
XMPP_Connected_Client map[string]bool
|
||||
XMPP_JID_Client string
|
||||
XMPP_Out chan interface{}
|
||||
}
|
||||
|
||||
func (g *GatewayInfo) Run() {
|
||||
|
|
|
|||
|
|
@ -45,16 +45,6 @@ func (g *GatewayInfo) ReceivedXMPP_Presence(presence *xmpp.Presence) {
|
|||
|
||||
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 {
|
||||
// Send presence to tell that the JID has been added to roster
|
||||
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
|
||||
if presence.Type == Type_unavailable {
|
||||
// Disconnect
|
||||
if len(g.XMPP_Connected_Client) <= 0 {
|
||||
g.XMPP_Disconnect()
|
||||
go g.SteamDisconnect()
|
||||
}
|
||||
// TODO multi client connected management
|
||||
g.XMPP_Disconnect()
|
||||
go g.SteamDisconnect()
|
||||
} else if presence.Type == Type_available {
|
||||
g.XMPP_Connect()
|
||||
// TODO multi client connected management
|
||||
go g.SteamConnect()
|
||||
transfertPresence = true
|
||||
}
|
||||
|
|
@ -80,12 +69,11 @@ func (g *GatewayInfo) ReceivedXMPP_Presence(presence *xmpp.Presence) {
|
|||
// Destination is Steam user
|
||||
if presence.Type == Type_unavailable {
|
||||
// Disconnect
|
||||
if len(g.XMPP_Connected_Client) <= 0 {
|
||||
g.XMPP_Disconnect()
|
||||
go g.SteamDisconnect()
|
||||
}
|
||||
// TODO multi client connected management
|
||||
g.XMPP_Disconnect()
|
||||
go g.SteamDisconnect()
|
||||
} else if presence.Type == Type_available {
|
||||
g.XMPP_Connect()
|
||||
// TODO multi client connected management
|
||||
go g.SteamConnect()
|
||||
transfertPresence = true
|
||||
}
|
||||
|
|
@ -124,12 +112,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 = "go-xmpp4steam v0.3.4"
|
||||
Version = "go-xmpp4steam v0.3.2"
|
||||
configurationFilePath = "xmpp4steam.cfg"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ func execCommandAdHoc(iq *xmpp.Iq) {
|
|||
// Command Auth Code
|
||||
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
|
||||
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}
|
||||
cmdXForm.Fields = append(cmdXForm.Fields, *field)
|
||||
|
|
@ -62,7 +61,6 @@ func execCommandAdHoc(iq *xmpp.Iq) {
|
|||
cmdXForm.Fields = append(cmdXForm.Fields, *field)
|
||||
|
||||
cmd.XForm = *cmdXForm
|
||||
cmd.Note = *note
|
||||
}
|
||||
reply.PayloadEncode(cmd)
|
||||
comp.Out <- reply
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ func Run() {
|
|||
comp = must(xmpp.NewComponentXMPP(stream, jid, Secret)).(*xmpp.XMPP)
|
||||
|
||||
mainXMPP()
|
||||
log.Printf("%sReach main method's end", LogInfo)
|
||||
go Run()
|
||||
ChanAction <- ActionMainMethodEnded
|
||||
}
|
||||
|
||||
func mainXMPP() {
|
||||
|
|
@ -158,7 +157,6 @@ func AddNewUser(jid, steamLogin, steamPwd string) {
|
|||
g.FriendSteamId = make(map[string]struct{})
|
||||
|
||||
g.XMPP_Out = comp.Out
|
||||
g.XMPP_Connected_Client = make(map[string]bool)
|
||||
|
||||
MapGatewayInfo[jid] = g
|
||||
go g.Run()
|
||||
|
|
|
|||
Loading…
Reference in New Issue