Skip to content

Commit df65231

Browse files
committed
registerplugin works on 1.1.X + with websocket now
1 parent b1f364e commit df65231

2 files changed

Lines changed: 140 additions & 231 deletions

File tree

register/README.markdown

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,48 @@ section:
1717
</head>
1818
```
1919

20-
Before you connect:
20+
To register a JID you need to listen for REGISTER und REGISTERED in
21+
your connection callback and use connection.register.connect() instead
22+
of connection.connect().
23+
24+
On REGISTER you need to inspect the ```connection.register.fields```
25+
object, fill in every field and call connection.register.submit().
26+
(There may be more fields than username and password!)
27+
28+
On REGISTERED you can can then call connection.authenticate() if you
29+
want to login normally with the account you just created.
30+
31+
You should also listen for CONFLICT, REGIFAIL and NOTACCEPTABLE to catch
32+
failure-status of registrations.
33+
34+
Example for registering a new account and logging in with it:
2135

2236
``` javascript
2337
var callback = function (status) {
2438
if (status === Strophe.Status.REGISTER) {
39+
// fill out the fields
2540
connection.register.fields.username = "juliet";
2641
connection.register.fields.password = "R0m30";
42+
// calling submit will continue the registration process
2743
connection.register.submit();
2844
} else if (status === Strophe.Status.REGISTERED) {
2945
console.log("registered!");
46+
// calling login will authenticate the registered JID.
3047
connection.authenticate();
48+
} else if (status === Strophe.Status.CONFLICT) {
49+
console.log("Contact already existed!");
50+
} else if (status === Strophe.Status.NOTACCEPTABLE) {
51+
console.log("Registration form not properly filled out.")
52+
} else if (status === Strophe.Status.REGIFAIL) {
53+
console.log("The Server does not support In-Band Registration")
3154
} else if (status === Strophe.Status.CONNECTED) {
32-
console.log("logged in!");
55+
// do something after successful authentication
3356
} else {
34-
// every other status a connection.connect would receive
57+
// Do other stuff
3558
}
3659
};
60+
3761
connection.register.connect("example.com", callback, wait, hold);
3862
```
3963

40-
After that you're logged in with a fresh smelling jid.
41-
42-
## ToDo
43-
44-
- write specs
64+
After that you're logged in with a fresh jid.

0 commit comments

Comments
 (0)