in progress
This commit is contained in:
parent
459b54955a
commit
9a39b69dce
10
commands.go
10
commands.go
|
@ -271,7 +271,6 @@ func (handler *CommandHandler) CommandLogout(ce *CommandEvent) {
|
||||||
Username: username,
|
Username: username,
|
||||||
Password: password,
|
Password: password,
|
||||||
}
|
}
|
||||||
|
|
||||||
portals := ce.User.GetPortals()
|
portals := ce.User.GetPortals()
|
||||||
//newPortals := ce.User.GetPortalsNew()
|
//newPortals := ce.User.GetPortalsNew()
|
||||||
//allPortals := newPortals[0:]
|
//allPortals := newPortals[0:]
|
||||||
|
@ -303,6 +302,15 @@ func (handler *CommandHandler) CommandLogout(ce *CommandEvent) {
|
||||||
Chats: make(map[string]skype.Conversation),
|
Chats: make(map[string]skype.Conversation),
|
||||||
}
|
}
|
||||||
ce.Reply("Logged out successfully.")
|
ce.Reply("Logged out successfully.")
|
||||||
|
|
||||||
|
//defer func() {
|
||||||
|
// if r := recover(); r != nil {
|
||||||
|
// fmt.Printf("close ReRefresh:%s\n", r)
|
||||||
|
// }
|
||||||
|
//}()
|
||||||
|
if ce.User.Conn.Refresh != nil {
|
||||||
|
ce.User.Conn.Refresh <- -1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommandLogout handles !logout command
|
// CommandLogout handles !logout command
|
||||||
|
|
27
user.go
27
user.go
|
@ -285,6 +285,7 @@ func (user *User) Connect(evenIfNoSession bool) bool {
|
||||||
//_ = user.Conn.SetClientName("matrix-skype bridge", "mx-wa", SkypeVersion)
|
//_ = user.Conn.SetClientName("matrix-skype bridge", "mx-wa", SkypeVersion)
|
||||||
user.log.Debugln("skype connection successful")
|
user.log.Debugln("skype connection successful")
|
||||||
user.Conn.AddHandler(user)
|
user.Conn.AddHandler(user)
|
||||||
|
|
||||||
return user.RestoreSession()
|
return user.RestoreSession()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,9 +372,10 @@ func (user *User) Login(ce *CommandEvent, name string, password string) (err err
|
||||||
userIds = append(userIds, userId)
|
userIds = append(userIds, userId)
|
||||||
}
|
}
|
||||||
ce.User.Conn.SubscribeUsers(userIds)
|
ce.User.Conn.SubscribeUsers(userIds)
|
||||||
go loopPresence(ce, user)
|
go loopPresence(user)
|
||||||
}
|
}
|
||||||
go user.Conn.Poll()
|
go user.Conn.Poll()
|
||||||
|
go user.monitorSession(ce)
|
||||||
|
|
||||||
user.ConnectionErrors = 0
|
user.ConnectionErrors = 0
|
||||||
user.JID = "8:" + user.Conn.UserProfile.Username + skypeExt.NewUserSuffix
|
user.JID = "8:" + user.Conn.UserProfile.Username + skypeExt.NewUserSuffix
|
||||||
|
@ -384,12 +386,27 @@ func (user *User) Login(ce *CommandEvent, name string, password string) (err err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func loopPresence(ce *CommandEvent, user *User) {
|
func (user *User) monitorSession(ce *CommandEvent) {
|
||||||
for {
|
user.Conn.Refresh = make(chan int)
|
||||||
if user.Conn.LoggedIn == false {
|
for x := range user.Conn.Refresh {
|
||||||
|
fmt.Println("monitorSession: ", x)
|
||||||
|
if x > 0 {
|
||||||
|
user.SetSession(user.Conn.LoginInfo)
|
||||||
|
} else {
|
||||||
ce.Reply("Session expired")
|
ce.Reply("Session expired")
|
||||||
break
|
close(user.Conn.Refresh)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
item, ok := <- user.Conn.Refresh
|
||||||
|
if !ok {
|
||||||
|
user.Conn.Refresh = nil
|
||||||
|
}
|
||||||
|
fmt.Println("monitorSession1", item, ok)
|
||||||
|
}
|
||||||
|
|
||||||
|
func loopPresence(user *User) {
|
||||||
|
for {
|
||||||
for cid, contact := range user.contactsPresence {
|
for cid, contact := range user.contactsPresence {
|
||||||
puppet := user.bridge.GetPuppetByJID(cid)
|
puppet := user.bridge.GetPuppetByJID(cid)
|
||||||
_ = puppet.DefaultIntent().SetPresence(event.Presence(strings.ToLower(contact.Availability)))
|
_ = puppet.DefaultIntent().SetPresence(event.Presence(strings.ToLower(contact.Availability)))
|
||||||
|
|
Loading…
Reference in New Issue