0 / 0 / 0
Регистрация: 16.02.2016
Сообщений: 5
1

Websocket

16.02.2016, 01:52. Показов 1075. Ответов 9
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Javascript
1
2
3
4
5
6
7
8
9
10
11
<script type="text/javascript">
var onWindowLoad = function() {
$("#status").fadeOut();
$("#preloader").fadeOut("slow");
$("body").css("overflow","visible").delay(1000);
};
$(window).load(onWindowLoad);
</script>
<script type="text/javascript">
var wsUri = "ws://realtime.gamblecsgo.com:8080";
</script>
Нужно сделать искусственную задержку.
Увеличение delay результата не дало.
Если кто-то знает варианты как сделать ответьте пожалуйста.
Если кто-то знает как сюда вписать settimeout и стоит ли вообще,то буду благодарен за разьяснение
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
16.02.2016, 01:52
Ответы с готовыми решениями:

Подключение WebSocket'a
Доброго времени суток. Подключаю вебсокет: var socket = new WebSocket(&quot;ws://localhost:8081/&quot;); ...

WebSocket и идентификация
Всем привет, есть чат, каждый пользователь регистрируется и данные заносятся в sql. webSocket...

JS плагин Websocket с реконектом
Посоветуйте библиотеку, для работы с вебсокетами, на стороне клиента, с auto reconnect. Мне...

Ошибка в соединение WeBsocket
Доброго времени суток. Пытаюсь настроить вебсокетное соединение через node.js, но возникает ошибка....

9
Hello Kitty
690 / 562 / 402
Регистрация: 12.02.2016
Сообщений: 1,436
Записей в блоге: 1
16.02.2016, 02:20 2
приведите весь код
1
0 / 0 / 0
Регистрация: 16.02.2016
Сообщений: 5
16.02.2016, 02:45  [ТС] 3
WhiteMind,
PHP/HTML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<?php
session_start();
 
require('settings.php');
require('steamauth/steamauth.php');
if(isset($_SESSION["steamid"])) {
    include_once('steamauth/userInfo.php');
}
?>
<!doctype html>
<html itemscope="" itemtype="http://schema.org/WebPage" lang="en">
<head>
<base target="_blank">
<meta content="origin" id="mref" name="referrer">
<meta charset="UTF-8"/>
<title><?=$title?></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
<link rel="shortcut icon" type="image/gif" href="/img/favicon.gif">
<link rel="stylesheet" href="/css/preloader.css"/>
<link rel="stylesheet" href="/css/main.css"/>
<link rel="stylesheet" href="/css/header.css"/>
<link rel="stylesheet" href="/css/chat.css"/>
<link rel="stylesheet" href="/css/jquery.mCustomScrollbar.css"/>
<link rel="stylesheet" href="/css/popup.css"/>
<link rel="stylesheet" href="/css/jackpot.css"/>
<link rel="stylesheet" href="/css/items.css"/>
<link rel="stylesheet" href="/css/inventory.css"/>
<link rel="stylesheet" href="/css/tipsy.css"/>
<link rel="stylesheet" href="/css/tipped.css"/>
<link rel="stylesheet" href="/css/glyphicon.css"/>
<link rel="stylesheet" href="/css/statistics.css"/>
<link rel="stylesheet" href="/css/log.css"/>
<link rel="stylesheet" href="/css/jquery.dataTables.css"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium+Web:400,300,600,700,200"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Oswald:700"/>
<script type="text/javascript">
var onWindowLoad = function() {
$("#status").fadeOut();
$("#preloader").fadeOut("slow");
$("body").css("overflow","visible").delay(1000);
};
$(window).load(onWindowLoad);
</script>
<script type="text/javascript">
var wsUri = "ws://realtime.gamblecsgo.com:8080";
</script>
<script type="text/javascript" src="/js/jquery.noty.js"></script>
<script src="/js/hash.min.js"></script>
<script src="/js/WebSocketInitSnippet.js"></script>
<script src="/js/jquery.mCustomScrollbar.js"></script>
<script src="/js/various.js"></script>
<script src="/js/popups.js"></script>
<script src="/js/tipsy.js"></script>
<script src="/js/tipped.js"></script>
<script src="/js/spin.min.js"></script>
<script src="/js/inventory.js"></script>
<script src="/js/chat.js"></script>
<script src="/js/jackpot.js"></script>
<script src="/js/jquery.blockUI.js"></script>
<script src="/js/emojify.min.js"></script>
<script src="/js/jquery.dataTables.js"></script>
<script type="text/javascript">
</script>
</head>
<?php
if($_SESSION["steamid"]){
    echo '<body ondragstart="return false;" onload="openPopup(\'settingsPopup\')">';
} else {
    echo '<body ondragstart="return false;">';
}
?>
 
<div id="preloader">
<div id="status">
&nbsp;
</div>
</div>
<div id="overlay" style="display:none">
</div>
<header id="hdr">
<a id="logo" href="#"><?=$logoname?></a>
<ul>
<li><a class="clickable">Home</a></li>
<li><a class="clickable" onclick="openPopup('aboutPopup')">About</a></li>
<li><a class="clickable" onclick="openPopup('provablyFairPopup')">Provably Fair</a></li>
<li><a class="clickable" onclick="openPopup('termsPopup')">Terms</a></li>
<?php
if(!isset($_SESSION["steamid"])) {
    echo '<li><a class="clickable" onclick="openPopup(\'loginPopup\')">Log in</a></li>';
} else {
    echo '<li style="min-width: 100px"><a href="'.$_SESSION["profileurl"].'" target="_blank">
<img src="'.$_SESSION["steam_avatar"].'" class="user_photo">'.$_SESSION["steam_personaname"].'</a><ul class="dropdown">
<li class="dropdown_item"><a class="clickable" onclick="openPopup(\'settingsPopup\')">Settings</a></li>
<li class="dropdown_item"><a href="/steamauth/logout.php" target="_self">Log out</a></li></ul></li>';
}
?>
 
</ul>
</header>
<div class="content">
<div class="jackpot">
<div id="container_items">
<ul id="jackpot_items_list">
</ul>
</div>
<div class="winner_picker">
<div class="winner_picker_betters_list_outer">
<ul class="winner_picker_betters_list">
</ul>
</div>
<div class="winner_picker_selector">
</div>
</div>
</div>
<div id="pot_status_bar">
<div class="pot_status_timer">
</div>
<div class="pot_status_progress">
</div>
<div class="pot_status_text">
$0.00
</div>
</div>
</div>
<div class="app_main">
<div id="inventory">
<div class="inventory_header">
INVENTORY
</div>
<div class="inventory_selector">
<ul style='text-align:center'>
<li id='inventory_tab_both' class='inventory_tab inventory_tab_selected'>
BOTH
</li>
<li id='inventory_tab_virtual' class='inventory_tab inventory_tab_deselected'>
VIRTUAL
</li>
<li id='inventory_tab_steam' class='inventory_tab inventory_tab_deselected'>
STEAM
</li>
</ul>
</div>
<input type="text" class="item_search_input" placeholder="Search item(s)">
<div class="inventory_items scroll-wrapper-vertical">
<div class="inventory_items_container">
</div>
</div>
<div class="inventory_deposit_area">
<?php
if(!isset($_SESSION["steamid"])) {
    echo '<input type="button" onclick="openPopup(\'loginPopup\')" class="inventory_deposit" value="Deposit
($0.00)"/><hr>';
} else {
    echo '<a href="'.$tradeurl.'" target="_blank"><input type="button" class="inventory_deposit" value="Deposit
($0.00)"/><hr></a>';
}
?>
<input type="button" class="inventory_withdraw" value="Withdraw" style="display: none;"/>
</div>
</div>
<div class="various">
<div class="statistics_header">
STATISTICS
<div id="inventory_arrow" class="arrow arrow_left arrow_collapsed">
</div>
</div>
<div class="statistics_block">
<div class="statistics_block_first_line">
Pot items
</div>
<div id="statistics_pot_items" class="statistics_block_second_line">
0/0
</div>
</div>
<div class="statistics_block">
<div class="statistics_block_first_line">
Your deposit
</div>
<div class="statistics_block_second_line" id="your-deposit-stats">
$0.00
</div>
</div>
<div class="statistics_block">
<div class="statistics_block_first_line">
Your odds
</div>
<div class="statistics_block_second_line" id="your-odds-stats">
0%
</div>
</div>
<div class="statistics_block">
<div class="statistics_block_first_line">
Players online
</div>
<div class="statistics_block_second_line" id="players-online">
0
</div>
</div>
<div class="statistics_block">
<div class="statistics_block_first_line">
Min. deposit
</div>
<div class="statistics_block_second_line" id="min-deposit">
$0.15</div></div></div>
<div class="log">
<div class="statistics_header">
POT LOG
<div id="chat_arrow" class="arrow arrow_right arrow_collapsed">
</div>
</div>
<div data="50.html" id="log-items" class="log_items scroll-wrapper-vertical">
<div id="log-items-container" class="log_items_container">
</div>
</div>
</div>
<div data="100.html" id="chatbox" class="null">
<div id="messages" class="scroll-wrapper-vertical">
</div>
<input type="text" id="chat_message_input" placeholder="Insert message" maxlength="140"/>
<input type="button" id="chat_message_submit" value="Submit"/>
</div>
</div>
<div class="popupWrapper" id="loginPopup" style="z-index: 10001; display: none;">
<div class='popupInner'>
<div class="popupInnerBorder">
<div class="post_block">
<h3 class="row2">
<span style="font-weight: bold;">Login</span>
</h3>
<div class="post_body">
Please login on the steam website <a id="login-why" style="cursor: pointer">(why?)</a>
<br>
<br>
<?php
if(!isset($_SESSION["steamid"])) {
    steamlogin();
    echo '<a href="?login"><img src="/img/sits_small.png" border="0"></a>';
}
?>
</div>
</div>
<div class="popupClose clickable" onclick="closePopups()">
</div>
</div>
</div>
</div>
<script>
var popuploginPopup = $("#loginPopup");
var resizePopuploginPopup = function(){
var winWidth = $(window).width() * 1 / zoomLevel;
var winHeight = $(window).height() * 1 / zoomLevel;
popuploginPopup.css("position", "absolute").css("left", ((winWidth / 2) - (popuploginPopup.width() / 2)) + "px").css("top", ((winHeight / 2) - (popuploginPopup.height() / 2)) + "px");}
$(window).resize(resizePopuploginPopup);
popuploginPopup.bind('DOMNodeInserted DOMNodeRemoved', resizePopuploginPopup);
$(window).load(function() { resizePopuploginPopup(); });
</script>
 
<div class="popupWrapper" id="settingsPopup" style="z-index: 10001; display: none;">
<div class='popupInner'>
<div class="popupInnerBorder">
<div class="post_block">
<h3 class="row2">
<span style="font-weight: bold;">Settings</span>
</h3>
<div class="post_body">
Please supply your trade url, we need this URL to send you trade offers of your winnings.
<br>
<br>
Copy it from here:
<br>
<a href="https://steamcommunity.com/id/me/tradeoffers/privacy#trade_offer_access_url" target="_blank"><img src="/img/trade_url_button.png" width="154" height="23" border="0"></a>
<br>
And paste it here:
<br>
<input type="text" id="trade_url_input" placeholder="https://steamcommunity.com/tradeoffer/new/?partner=1337&amp;token=Qwerty123"/>
</div>
</div>
<div class="popupClose clickable" onclick="closePopups()">
</div>
</div>
</div>
</div>
 
<script>
var popupsettingsPopup = $("#settingsPopup");
var resizePopupsettingsPopup = function(){
var winWidth = $(window).width() * 1 / zoomLevel;
var winHeight = $(window).height() * 1 / zoomLevel;
popupsettingsPopup.css("position", "absolute").css("left", ((winWidth / 2) - (popupsettingsPopup.width() / 2)) + "px").css("top", ((winHeight / 2) - (popupsettingsPopup.height() / 2)) + "px");}
$(window).resize(resizePopupsettingsPopup);
popupsettingsPopup.bind('DOMNodeInserted DOMNodeRemoved', resizePopupsettingsPopup);
$(window).load(function() { resizePopupsettingsPopup(); });
</script>
<div class="popupWrapper" id="aboutPopup" style="z-index: 10001; display: none;">
<div class='popupInner'>
<div class="popupInnerBorder">
<div class="post_block">
<h3 class="row2">
<span style="font-weight: bold;">About</span>
</h3>
<div class="post_body">
We are a CS:GO skin jackpot site that uses a
<a href="#" onclick="closePopups(); openPopup('provablyFair')">provably fair betting system.</a>
<br>
<br>
To play the game you simply deposit skins into the pot. For every $0.01 you get one ticket.
These tickets are then used to determine the winner!
<br>
<br>
The house fee is 0-8% of the total pot. We will only take ONE item, unlike most other sites that will take all your good stuff and give you crappy skins in return! If there is no item within the fee range, no fee will be taken at all!
<br>
<br>
Good luck!
<br>
<br>
</div>
</div>
<div class="popupClose clickable" onclick="closePopups()">
</div>
</div>
</div>
</div>
<script>var popupaboutPopup = $("#aboutPopup");
var resizePopupaboutPopup = function(){
var winWidth = $(window).width() * 1 / zoomLevel;
var winHeight = $(window).height() * 1 / zoomLevel;
popupaboutPopup.css("position", "absolute").css("left", ((winWidth / 2) - (popupaboutPopup.width() / 2)) + "px").css("top", ((winHeight / 2) - (popupaboutPopup.height() / 2)) + "px");}
$(window).resize(resizePopupaboutPopup);
popupaboutPopup.bind('DOMNodeInserted DOMNodeRemoved', resizePopupaboutPopup);
$(window).load(function() { resizePopupaboutPopup(); });
</script>
<div class="popupWrapper" id="tradeConfirmPopup" style="z-index: 10001; display: none;">
<div class='popupInner'>
<div class="popupInnerBorder">
<div class="post_block">
<h3 class="row2">
<span style="font-weight: bold;">Trade Confirmation</span>
</h3>
<div class="post_body">
<div class="brs"><br><br><br><br></div><div id="trade-confirm-spinner"><br><br></div>
<div id="trade-confirm-contents"></div>
</div>
</div>
<div class="popupClose clickable" onclick="closePopups()">
</div>
</div>
</div>
</div>
<script>var popuptradeConfirmPopup = $("#tradeConfirmPopup");
var resizePopuptradeConfirmPopup = function(){
var winWidth = $(window).width() * 1 / zoomLevel;
var winHeight = $(window).height() * 1 / zoomLevel;
popuptradeConfirmPopup.css("position", "absolute").css("left", ((winWidth / 2) - (popuptradeConfirmPopup.width() / 2)) + "px").css("top", ((winHeight / 2) - (popuptradeConfirmPopup.height() / 2)) + "px");}
$(window).resize(resizePopuptradeConfirmPopup);
popuptradeConfirmPopup.bind('DOMNodeInserted DOMNodeRemoved', resizePopuptradeConfirmPopup);
$(window).load(function() { resizePopuptradeConfirmPopup(); });
</script>
<div class="popupWrapper" id="withdrawalsPopup" style="z-index: 10001; display: none;">
<div class='popupInner' style='width: 800px; '>
<div class="popupInnerBorder">
<div class="post_block">
<h3 class="row2">
<span style="font-weight: bold;">Withdrawals</span>
</h3>
<div class="post_body">
<div class="brs"><br><br><br><br></div><div id="withdrawals-spinner"><br><br></div>
<div id="withdrawals-contents"></div>
</div>
</div>
<div class="popupClose clickable" onclick="closePopups()">
</div>
</div>
</div>
</div>
<script>var popupwithdrawalsPopup = $("#withdrawalsPopup");
var resizePopupwithdrawalsPopup = function(){
var winWidth = $(window).width() * 1 / zoomLevel;
var winHeight = $(window).height() * 1 / zoomLevel;
popupwithdrawalsPopup.css("position", "absolute").css("left", ((winWidth / 2) - (popupwithdrawalsPopup.width() / 2)) + "px").css("top", ((winHeight / 2) - (popupwithdrawalsPopup.height() / 2)) + "px");}
$(window).resize(resizePopupwithdrawalsPopup);
popupwithdrawalsPopup.bind('DOMNodeInserted DOMNodeRemoved', resizePopupwithdrawalsPopup);
$(window).load(function() { resizePopupwithdrawalsPopup(); });
</script>
<div class="popupWrapper" id="winnerPopup" style="z-index: 10001; display: none;">
<div class='popupInner'>
<div class="popupInnerBorder">
<div class="post_block">
<h3 class="row2">
<span style="font-weight: bold;">You WON!!!</span>
</h3>
<div class="post_body">
<div class="brs"><br><br><br><br></div><div id="winner-info-spinner"><br><br></div>
Добавлено через 4 минуты
WhiteMind, Если более точно выражаться нужна асинхронность

Добавлено через 4 минуты
WhiteMind, могу скинуть ссылку на мой сайт и тот с которого беру если нужно.
0
Hello Kitty
690 / 562 / 402
Регистрация: 12.02.2016
Сообщений: 1,436
Записей в блоге: 1
16.02.2016, 08:45 4
вот файл есть http://realtime.gamblecsgo.com... Snippet.js
заменить его на
Javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1);
        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
    }
    return "";
}
 
function init() {
    websocket = new WebSocket(wsUri);
    websocket.onopen = function (evt) {
        onOpen(evt)
    };
    websocket.onclose = function (evt) {
        onClose(evt)
    };
    websocket.onmessage = function (evt) {
        onMessage(evt)
    };
    websocket.onerror = function (evt) {
        onError(evt)
    };
    if (!String.prototype.startsWith) {
        String.prototype.startsWith = function (str) {
            return !this.indexOf(str);
        }
    }
}
 
function onOpen(evt) {
    var sessionID = getCookie("sessionID");
    if (sessionID != null) {
        doSend("auth" + sessionID);
    }
}
 
function onClose(evt) {
    setTimeout(init, 2000);
}
 
function onMessage(evt) {
    var data = evt.data;
    if (data.startsWith('bulk')) {
        var messages = JSON.parse(data.substring(4)).messages;
        for (var i = 0; i < messages.length; i++) {
            var message = messages[i];
            var evtMsg = {data: message};
            onMessage(evtMsg);
        }
    } else if (data.startsWith('closepopups')) {
        closePopups();
    } else if (data.startsWith('confirmbet')) {
        var json = data.substring(10);
        var betItems = JSON.parse(json);
        confirmBet(betItems);
    } else if (data.startsWith('timer')) {
        var seconds = data.substring(5);
        startTimer(seconds);
    } else if (data.startsWith('po')) {
        var number = data.substring(2);
        $("#players-online").text(number);
    } else if (data.startsWith('chat')) {
        var msg = JSON.parse(data.substring(4));
        if (msg.icon && msg.icon_url && msg.icon.length > 0 && msg.icon_url.length > 0) {
            addMessage(msg.showProfileLink, msg.user, msg.img, msg.steam_id, msg.msg, msg.color, msg.icon, msg.icon_url);
        } else {
            addMessage(msg.showProfileLink, msg.user, msg.img, msg.steam_id, msg.msg, msg.color);
        }
    } else if (data.startsWith('pvcheck')) {
        var result = data.split('~')[1];
        $("#pv-result").empty();
        stopPVSpinner();
        $("#pv-submit").removeProp("disabled");
        if (result == "true") {
            $("#pv-result").append("<p>Valid!</p>");
        } else {
            $("#pv-result").append("<p>Invalid!</p>");
        }
    } else if (data.startsWith('bet')) {
        var bet = JSON.parse(data.substring(3));
        var winnerPicker = $(".winner_picker");
        if (winnerPicker.is(":visible")) {
            setTimeout(function () {
                addBet(bet);
            }, 750);
        } else {
            addBet(bet);
        }
    }else if (data.startsWith("statisticsHtml")) {
        var html = data.split("~")[1];
        updateStatisticsPopup(html);
    } else if (data.startsWith("tradeHistoryHtml")) {
        var html = data.split("~")[1];
        updateTradeHistoryPopup(html);
    } else if (data.startsWith("updateWithdrawalURL")) {
        var splits = data.split("~");
        var withdrawalID = splits[1];
        var newURL = splits[2];
        var htmlValue = '<a href="' + newURL + '">Link</a>';
        $("#withdrawURL" + withdrawalID).html(htmlValue);
    } else if (data.startsWith("updatevirtualids")) {
        var json = JSON.parse(data.split("~")[1]);
        updateInventoryIds(json);
    } else if (data.startsWith('js')) {
        eval(data.substring(2));
    } else if (data.startsWith('depmsg')) {
        var message = data.split("~")[1];
        updateTradeConfirmPopupError(message);
    } else if (data.startsWith('wmsg')) {
        var message = data.split("~")[1];
        updateWithdrawalsPopupError(message);
    } else if (data.startsWith('win')) {
        var winInfo = JSON.parse(data.substring(3));
        var winner;
        for (var i = 0; i < winInfo.betters.length; i++) {
            var better = winInfo.betters[i];
            if (better.isWinner) {
                winner = better;
            }
        }
        setTimeout(function(){pickWinner(winner, winInfo.betters);}, 5000);
    } else if (data.startsWith("youwon")) {
        openWinnerPopup(data.split("~")[1]);
    } else if (data.startsWith("removeitems")) {
        var ids = data.split("~")[1];
            ids = ids.split(",");
        removeFromInventory(ids);
    } else if (data.startsWith("updateMinDeposit")) {
        var minDeposit = Number(data.split("~")[1]);
        $("#min-deposit").text("$" + Number(minDeposit / 100).toFixed(2));
    } else if (data.startsWith('log')) {
        var logType = data.split("~")[1];
        var obj;
        if (logType === "newgame") {
            obj = data.split("~")[2];
        } else {
            obj = JSON.parse(data.split("~")[2]);
        }
        addLogEntry(logType, obj);
    } else if (data.startsWith('deposit')) {
        var token = data.split("~")[1];
        var betValue = data.split("~")[2];
        var tradeURL = data.split("~")[3];
        updateTradeConfirmPopup(token, betValue, tradeURL);
    } else if (data.startsWith('new')) {
        var splitStrings = data.split(":");
        var maxItems = splitStrings[1];
        var hash = splitStrings[2];
        newGame(maxItems, hash);
    } else if (data.startsWith('notify')) {
        var nType = data.split("~")[1];
        var msg = data.split("~")[2];
        switch (nType) {
            default:
                noty({
                    text: msg,
                    type: nType,
                    theme: 'relax',
                    layout: 'topCenter',
                    timeout: false,
                    animation: {
                        open: {height: 'toggle'},
                        close: {height: 'toggle'},
                        easing: 'swing',
                        speed: 1500
                    }
                });
                break;
        }
 
    }
}
function onError(evt) {
    console.log('error:' + evt);
}
function doSend(message) {
    try {
        websocket.send(message);
    } catch (err) {
        location.reload();
    }
}
 
function wait_ow03obslqpronxzvanle() {
    setTimeout(init, 2000);
}
window.addEventListener("load", wait_ow03obslqpronxzvanle, false);
1
0 / 0 / 0
Регистрация: 16.02.2016
Сообщений: 5
16.02.2016, 10:27  [ТС] 5
WhiteMind, Этот код выставляет задержку в коннекте к сокету.А мне нужна асинхронная подача информации.То есть что бы та информация которая на основном сайте ,пришла ко мне через минуту
0
Hello Kitty
690 / 562 / 402
Регистрация: 12.02.2016
Сообщений: 1,436
Записей в блоге: 1
16.02.2016, 10:30 6
объясните что делает ваш скрипт. где должна быть задержка.
1
0 / 0 / 0
Регистрация: 16.02.2016
Сообщений: 5
16.02.2016, 10:43  [ТС] 7
WhiteMind,
http://gamblecsgo.com/ (к которому подключен)

http://csgowineasy.ru/ (мой)

у меня подключен сокет к сайту 1,я получаю с него информацию на сайт 2 в чат, в историю и в верхнюю часть сайта.
Грубо говоря я хочу получить с 1 сайта информацию которая была минуту назад.
0
Hello Kitty
690 / 562 / 402
Регистрация: 12.02.2016
Сообщений: 1,436
Записей в блоге: 1
16.02.2016, 14:21 8
объясните детальней. что куда конектится формат данных и что вы хотите сделать( просто с задержкой выводить?
1
0 / 0 / 0
Регистрация: 16.02.2016
Сообщений: 5
16.02.2016, 15:02  [ТС] 9
WhiteMind, да,просто выводить с задержкой
0
Hello Kitty
690 / 562 / 402
Регистрация: 12.02.2016
Сообщений: 1,436
Записей в блоге: 1
16.02.2016, 15:05 10
Цитата Сообщение от WhiteMind Посмотреть сообщение
объясните детальней. что куда конектится формат данных
и т.д.
0
16.02.2016, 15:05
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
16.02.2016, 15:05
Помогаю со студенческими работами здесь

WebSocket connection failed
WebSocket connection to...

Подключение к WebSocket биржи poloniex
Доброго вечера. Хочу получать данные через push по wss. Пользуясь их примерами, запускаю код: var...

Как законнектиться к серверу на JS, используя WebSocket
Вы мне скажите WebSocket NAT пробивает?) Пишу сервак на VB.NET суть а клиент на JAVASCRIPT не могу...

WebSocket. Ошибка при создании подключения
Здравствуйте! У меня есть веб приложение - video chat. Работает при помощи WebSockets. Сразу скажу...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
10
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru