{"action":"created","issue":{"url":"https://api.github.com/repos/jsxc/jsxc/issues/269","repository_url":"https://api.github.com/repos/jsxc/jsxc","labels_url":"https://api.github.com/repos/jsxc/jsxc/issues/269/labels{/name}","comments_url":"https://api.github.com/repos/jsxc/jsxc/issues/269/comments","events_url":"https://api.github.com/repos/jsxc/jsxc/issues/269/events","html_url":"https://github.com/jsxc/jsxc/issues/269","id":128175499,"number":269,"title":"[Discussion] How to implement presence ","user":{"login":"LEDfan","id":2996275,"avatar_url":"https://avatars.githubusercontent.com/u/2996275?v=3","gravatar_id":"","url":"https://api.github.com/users/LEDfan","html_url":"https://github.com/LEDfan","followers_url":"https://api.github.com/users/LEDfan/followers","following_url":"https://api.github.com/users/LEDfan/following{/other_user}","gists_url":"https://api.github.com/users/LEDfan/gists{/gist_id}","starred_url":"https://api.github.com/users/LEDfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LEDfan/subscriptions","organizations_url":"https://api.github.com/users/LEDfan/orgs","repos_url":"https://api.github.com/users/LEDfan/repos","events_url":"https://api.github.com/users/LEDfan/events{/privacy}","received_events_url":"https://api.github.com/users/LEDfan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jsxc/jsxc/labels/discussion","name":"discussion","color":"d1d1d1"},{"url":"https://api.github.com/repos/jsxc/jsxc/labels/owncloud","name":"owncloud","color":"bfd4f2"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2016-01-22T15:11:16Z","updated_at":"2016-02-11T09:04:16Z","closed_at":"2016-02-11T09:04:16Z","body":"In this issue I would like to discuss several things about the presence implementation. \r\n\r\n\r\n## XMPP\r\n\r\nSo if I understand correctly precense in XMPP works this way:\r\n - you have 6 statuses which the user can choose (online, offline, away, chatty, extended away and do not disturb). I though that you could set a custom state, but it looks like this isn't implemented in JSXC. (looks good to me :P )\r\n - when you start a chat session (i.e. opening ownCloud) the XMPP server (owncloud) sends the presence of all users with the following stanza: \r\n````\r\n<body xmlns='http://jabber.org/protocol/httpbind'><presence xmlns='jabber:client' from='user@host' to='user@host' type='unavailable'/></body>\r\n```` \r\n - a user can change it's current state via the UI, the client sends it's state to the server via:\r\n````\r\n<body rid='' xmlns='http://jabber.org/protocol/httpbind' sid=''><presence xmlns='jabber:client'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://jsxc.org/' ver='u2kAg/CbVmVZhsu+lZrkuLLdO+0='/><show>chat</show></presence></body>\r\n````\r\n - when a user logs in, the client sends it current state via:\r\n````\r\n<body xmlns='http://jabber.org/protocol/httpbind' ><presence xmlns='jabber:client'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='' ver='u2kAg/CbVmVZhsu+lZrkuLLdO+0='/></presence></body>\r\n````\r\n````\r\n<body rid='' xmlns='http://jabber.org/protocol/httpbind' sid=''><presence xmlns='jabber:client'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://jsxc.org/' ver='u2kAg/CbVmVZhsu+lZrkuLLdO+0='/><show>dnd</show></presence></body>\r\n````\r\n - only the client keeps track of a user current state (so logging into a new client change the user's current state)\r\n - there is a subscription model where the user can choose which of the user's presence he wants to keep track\r\n - @sualko is it possible for a user to login at one server multiple times simultaneous? If I try with ownCloud, the last logged in session is master and the other connections are logged out.\r\n\r\n## Implementation in ownCloud\r\n -  I would assume/hard code that all users are subscribed to each other.\r\n - We would need a place to store someone's presence. A database is always available so we should start with that. Basically we only need to store a field `user` and a field `presence`. Then when a user opens a connection it sends the presence of all other users, fetched from this table. \r\n - like with the locking mechanism we could use Memcache for this too. This wouldn't be too hard since it's just a key/value. Will all memcache backends keep this information for long enough time? So when someone restart PHP and is using APCU is the information than gone? Same with a reboot. @DeepDiver1975 @MorrisJobke @PVince81 do you know this? :smiley: EDIT:\r\n - redis and memcache are persistent, xcache and apc(u) not. I think the best option would be to let the user decide. If he is using redis/memcache there isn't a risc and when he is using apcu/xcache there is a small risc. (and it's only for online state not very important imo)\r\n\r\n@sualko is my understanding of the XMPP presence correct? "},"comment":{"url":"https://api.github.com/repos/jsxc/jsxc/issues/comments/182773527","html_url":"https://github.com/jsxc/jsxc/issues/269#issuecomment-182773527","issue_url":"https://api.github.com/repos/jsxc/jsxc/issues/269","id":182773527,"user":{"login":"sualko","id":2974196,"avatar_url":"https://avatars.githubusercontent.com/u/2974196?v=3","gravatar_id":"","url":"https://api.github.com/users/sualko","html_url":"https://github.com/sualko","followers_url":"https://api.github.com/users/sualko/followers","following_url":"https://api.github.com/users/sualko/following{/other_user}","gists_url":"https://api.github.com/users/sualko/gists{/gist_id}","starred_url":"https://api.github.com/users/sualko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sualko/subscriptions","organizations_url":"https://api.github.com/users/sualko/orgs","repos_url":"https://api.github.com/users/sualko/repos","events_url":"https://api.github.com/users/sualko/events{/privacy}","received_events_url":"https://api.github.com/users/sualko/received_events","type":"User","site_admin":false},"created_at":"2016-02-11T09:04:16Z","updated_at":"2016-02-11T09:04:16Z","body":"owncloud/jsxc.chat#19 was merged"}}