switch to directed presence for pair requests
Testing between Google Talk and prosody, the directed IQ messages were not received. Google Talk probably only relays them between clients using the same account. I first tried even more directed presence, with each client JID being sent a separate presence, but that didn't work on Google Talk, particularly it was ignored when one client sent it to another client using the same account. So, presence directed at the user@host of the client to pair with. Tested working between Google Talk and prosody (in both directions), as well as between two clients with the same account on Google Talk, and two clients with the same account on prosody. Only problem with this form of directed presence is that if I also use it for git pushes, more clients than are interested in a push's data will receive it. So I may need some better approach, or a hybrid between directed IQ and directed presence.
This commit is contained in:
parent
5108d4b364
commit
17e84a8096
4 changed files with 44 additions and 40 deletions
|
@ -119,18 +119,15 @@ decodeStanza fulljid s@(ReceivedPresence p)
|
|||
| presenceFrom p == Just fulljid = [Ignorable p]
|
||||
| not (null pushed) = impliedp $ GotNetMessage $ NotifyPush pushed
|
||||
| isPresenceQuery p = impliedp $ GotNetMessage QueryPresence
|
||||
| otherwise = [PresenceMessage p]
|
||||
| otherwise = case decodePairingNotification p of
|
||||
Nothing -> [PresenceMessage p]
|
||||
Just pn -> impliedp $ GotNetMessage pn
|
||||
where
|
||||
-- Some things are sent via presence, so imply a presence message,
|
||||
-- along with their real value.
|
||||
-- Things sent via presence imply a presence message,
|
||||
-- along with their real meaning.
|
||||
impliedp v = [PresenceMessage p, v]
|
||||
pushed = concat $ catMaybes $ map decodePushNotification $
|
||||
presencePayloads p
|
||||
decodeStanza _ s@(ReceivedIQ iq)
|
||||
| iqType iq == IQError = [ProtocolError s]
|
||||
| otherwise = case decodePairingNotification iq of
|
||||
Nothing -> [Unknown s]
|
||||
Just pn -> [GotNetMessage pn]
|
||||
decodeStanza _ s = [Unknown s]
|
||||
|
||||
{- Waits for a NetMessager message to be sent, and relays it to XMPP. -}
|
||||
|
@ -141,9 +138,8 @@ relayNetMessage fulljid = convert <$> waitNetMessage
|
|||
convert QueryPresence = putStanza $ presenceQuery
|
||||
convert (PairingNotification stage t u) = case parseJID t of
|
||||
Nothing -> noop
|
||||
Just tojid -> do
|
||||
liftIO $ print $ pairingNotification stage u tojid fulljid
|
||||
putStanza $ pairingNotification stage u tojid fulljid
|
||||
Just tojid -> putStanza $
|
||||
pairingNotification stage u tojid fulljid
|
||||
|
||||
{- Runs the client, handing restart events. -}
|
||||
restartableClient :: IO () -> Assistant ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue