Skip to content

Commit

Permalink
Corrected web socket connection and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
volodalexey committed Oct 2, 2015
1 parent a1f4fc4 commit fefdf72
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 47 deletions.
65 changes: 23 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,32 @@ https://s-p-a-chat.herokuapp.com/
> To use chat you need to enable "load unsafe script" by clicking on "shield" in address bar
###### To connect to each other make following (just a test connection peer-to-peer users):
A: create user & login & enable unsafe script

B: create user & login & enable unsafe script

A: goes to right panel and copies user id

A: sends this user id to B (e.g. by email)

A: goes to left panel "make friends"

A: enables checkbox "Ready for request"

B: goes to left panel "make friends"

B: inserts received user id into user id and fills some invitation message

B: clicks "Send request"

A: If everything goes well, A receives message and confirms friendship
##### To connect to each other make following (just a test connection peer-to-peer users):
- A: create user & login & enable unsafe script
- B: create user & login & enable unsafe script
- A: goes to right panel and copies user id
- A: sends this user id to B (e.g. by email)
- A: goes to left panel "make friends"
- A: enables checkbox "Ready for request"
- B: goes to left panel "make friends"
- B: inserts received user id into user id and fills some invitation message
- B: clicks "Send request"
- A: If everything goes well, A receives message and confirms friendship

After WebRTC find the way to each other A and B should have friends under "My users"

###### To connect to chat make following:
A: create user & login & enable unsafe script

B: create user & login & enable unsafe script

A: goes to left panel under "Create chat"

A: clicks "auto handshake" & sees new chat

A: goes to opened chat "settings" and copies chat id

A: checks "Ready for new chat users requests"

A: sends this chat id to B (e.g. by email)

B: goes to left panel "make friends"

B: inserts received user id into user id and fills some invitation message

B: clicks "Send request"

A: If everything goes well, A receives message and confirms friendship
##### To connect to chat make following:
- A: create user & login & enable unsafe script
- B: create user & login & enable unsafe script
- A: goes to left panel under "Create chat"
- A: clicks "auto handshake" & sees new chat
- A: goes to opened chat "settings" and copies chat id
- A: checks "Ready for new chat users requests"
- A: sends this chat id to B (e.g. by email)
- B: goes to left panel "make friends"
- B: inserts received user id into user id and fills some invitation message
- B: clicks "Send request"
- A: If everything goes well, A receives message and confirms friendship

After WebRTC find the way to each other A and B should have friends under "My users"

Expand Down
5 changes: 5 additions & 0 deletions development/configs/localization_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -508,5 +508,10 @@
"id": 102,
"en": "User with such username is already exist!",
"ru": "Пользователь с таким именем уже существует!"
},
{
"id": 103,
"en": "WebSocket connection abort",
"ru": "Соединение по веб сокету прервано"
}
]
23 changes: 18 additions & 5 deletions development/js/app/websocket.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
define('websocket', [
'throw_event_core',
'extend_core',
'id_core'
'id_core',
'popap_manager'
],
function(
throw_event_core,
extend_core,
id_core
id_core,
popap_manager
) {

var websocket = function() {
this.bindContexts();
this.responseCallbacks = [];
this.protocol = window.location.origin.indexOf('https') >= 0 ? 'wss://' : 'ws://';
};

websocket.prototype = {
Expand All @@ -32,7 +35,7 @@ define('websocket', [
},

create: function() {
this.socket = new WebSocket('ws://' + window.location.host + this.href);
this.socket = new WebSocket(this.protocol + window.location.host + this.href);
},

dispose: function() {
Expand Down Expand Up @@ -74,9 +77,19 @@ define('websocket', [
if (event.wasClean) {
console.warn('WebSocket connection closed');
} else {
console.error(new Error('WebSocket connection abort'));
popap_manager.renderPopap(
'error',
{message: 103},
function(action) {
switch (action) {
case 'confirmCancel':
popap_manager.onClose();
break;
}
}
);
}
console.log('Code: ' + event.code + ' reason: ' + event.reason);
console.warn('Code: ' + event.code + ' reason: ' + event.reason);
},

onMessage: function(event) {
Expand Down

0 comments on commit fefdf72

Please sign in to comment.