Add resource for Steam JID

This commit is contained in:
Chteufleur 2016-04-23 11:23:58 +02:00
parent e064b71660
commit 7368dce789
3 changed files with 6 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import (
const ( const (
SentryDirectory = "sentries/" SentryDirectory = "sentries/"
resource = "go-xmpp4steam"
) )
type GatewayInfo struct { type GatewayInfo struct {

View File

@ -46,6 +46,7 @@ func (g *GatewayInfo) ReceivedXMPP_Presence(presence *xmpp.Presence) {
transfertPresence := false transfertPresence := false
jid := strings.SplitN(presence.From, "/", 2) jid := strings.SplitN(presence.From, "/", 2)
steamJid := strings.SplitN(strings.SplitN(presence.To, "/", 2)[0], "@", 2)
if len(jid) == 2 { if len(jid) == 2 {
// Resource exist —> client speaking // Resource exist —> client speaking
if presence.Type == Type_available { if presence.Type == Type_available {
@ -56,10 +57,9 @@ func (g *GatewayInfo) ReceivedXMPP_Presence(presence *xmpp.Presence) {
} }
if presence.Type == Type_probe { if presence.Type == Type_probe {
steamId := strings.SplitN(strings.SplitN(presence.To, "/", 2)[0], "@", 2)[0] steamFriendStatus := g.FriendSteamId[steamJid[0]]
steamFriendStatus := g.FriendSteamId[steamId]
if steamFriendStatus != nil { if steamFriendStatus != nil {
g.SendXmppPresence(steamFriendStatus.XMPP_Status, steamFriendStatus.XMPP_Type, "", steamId+"@"+XmppJidComponent, steamFriendStatus.SteamGameName, steamFriendStatus.SteamName) g.SendXmppPresence(steamFriendStatus.XMPP_Status, steamFriendStatus.XMPP_Type, "", steamJid[0]+"@"+XmppJidComponent, steamFriendStatus.SteamGameName, steamFriendStatus.SteamName)
} }
} else if presence.Type == Type_subscribe { } else if presence.Type == Type_subscribe {
@ -155,7 +155,7 @@ func (g *GatewayInfo) SendXmppPresence(status, tpye, to, from, message, nick str
// TODO add an option to allow message comming directly from the gateway // TODO add an option to allow message comming directly from the gateway
p.From = XmppJidComponent p.From = XmppJidComponent
} else { } else {
p.From = from p.From = from+"/"+resource
} }
log.Printf("%sSend presence %v", LogXmppInfo, p) log.Printf("%sSend presence %v", LogXmppInfo, p)

View File

@ -15,7 +15,7 @@ import (
) )
const ( const (
Version = "v0.3.7d" Version = "v0.3.7"
configurationFilePath = "xmpp4steam.cfg" configurationFilePath = "xmpp4steam.cfg"
) )