1
0
Fork 0

Finalize steam user subscribtion

This commit is contained in:
Chteufleur 2016-04-09 13:47:31 +02:00
parent 387a0b7e5a
commit abfe6de004
2 changed files with 27 additions and 3 deletions

View File

@ -15,7 +15,7 @@ import (
) )
const ( const (
Version = "go-xmpp4steam v0.1.5" Version = "go-xmpp4steam v0.1.6"
configurationFilePath = "xmpp4steam.cfg" configurationFilePath = "xmpp4steam.cfg"
) )
@ -95,6 +95,8 @@ func gatewayXmppSteamAction() {
func gatewayXmppSteamPresence() { func gatewayXmppSteamPresence() {
for { for {
status := <-xmpp.ChanPresence status := <-xmpp.ChanPresence
tpye := <-xmpp.ChanPresence
var steamStatus steamlang.EPersonaState var steamStatus steamlang.EPersonaState
switch status { switch status {
@ -114,6 +116,7 @@ func gatewayXmppSteamPresence() {
} }
steam.SendPresence(steamStatus) steam.SendPresence(steamStatus)
xmpp.SendPresence(status, tpye, Version)
} }
} }

View File

@ -70,8 +70,8 @@ func mainXMPP() {
for x := range comp.In { for x := range comp.In {
switch v := x.(type) { switch v := x.(type) {
case *xmpp.Presence: case *xmpp.Presence:
if strings.SplitN(v.From, "/", 2)[0] == PreferedJID && v.To == JidStr && v.Type != Type_probe { if strings.SplitN(v.From, "/", 2)[0] == PreferedJID && v.Type != Type_probe {
if v.Type == Type_unavailable { if v.Type == Type_unavailable && v.To == JidStr {
delete(setJIDconnected, v.From) delete(setJIDconnected, v.From)
log.Printf("%sPresence reçut unavailable", LogDebug) log.Printf("%sPresence reçut unavailable", LogDebug)
if len(setJIDconnected) <= 0 { if len(setJIDconnected) <= 0 {
@ -79,6 +79,8 @@ func mainXMPP() {
Disconnect() Disconnect()
ChanAction <- ActionDeconnexion ChanAction <- ActionDeconnexion
} }
} else if v.Type == Type_subscribe {
SendPresenceFrom("", Type_subscribed, v.To, "", "")
} else { } else {
setJIDconnected[v.From] = true setJIDconnected[v.From] = true
log.Printf("%sPresence reçut", LogDebug) log.Printf("%sPresence reçut", LogDebug)
@ -87,6 +89,7 @@ func mainXMPP() {
} }
ChanPresence <- v.Show ChanPresence <- v.Show
ChanPresence <- v.Type
} }
case *xmpp.Message: case *xmpp.Message:
@ -129,6 +132,7 @@ func SendPresence(status, tpye, message string) {
} }
func SendPresenceFrom(status, tpye, from, message, nick string) { func SendPresenceFrom(status, tpye, from, message, nick string) {
/*
if message == "" { if message == "" {
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Nick: nick} comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Nick: nick}
} else if nick == "" { } else if nick == "" {
@ -138,6 +142,23 @@ func SendPresenceFrom(status, tpye, from, message, nick string) {
} else { } else {
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Status: message, Nick: nick} comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Status: message, Nick: nick}
} }
*/
p := xmpp.Presence{To: PreferedJID, From: from}
if status != "" {
p.Show = status
}
if tpye != "" {
p.Type = tpye
}
if message != "" {
p.Status = message
}
if nick != "" {
p.Nick = nick
}
comp.Out <- p
} }
func SendMessage(from, message string) { func SendMessage(from, message string) {