Completed
Pull Request — master (#234)
by Дмитрий
07:51
created

SimpleRequest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 55
rs 10
c 2
b 1
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 48 1
1
<?php
2
namespace PHPDaemon\SockJS\Examples;
3
4
use PHPDaemon\Core\Daemon;
5
use PHPDaemon\Core\Debug;
6
use PHPDaemon\HTTPRequest\Generic;
7
8
class SimpleRequest extends Generic
9
{
10
    /**
11
     * Called when request iterated.
12
     * @return integer Status.
0 ignored issues
show
Documentation introduced by
Should the return type not be integer|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
13
     */
14
    public function run()
15
    {
16
        $this->header('Content-Type: text/html');
17
        ?>
18
<!DOCTYPE html>
19
<html>
20
<head>
21
	<title>SockJS test page</title>
22
	<script src="//cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js"></script>
23
</head>
24
<body>
25
	<script type="text/javascript">
26
		var sock, logElem;
27
28
		function addLog(msg) {
29
			logElem.innerHTML = msg + '<br />' + logElem.innerHTML;
30
		}
31
32
		function create() {
33
			logElem = document.getElementById('log');
34
			sock = new SockJS('http://'+document.domain+':8068/sockjs/');
35
			sock.onopen = function () {
36
				addLog('SockJS opened');
37
			}
38
			sock.onmessage = function (e) {
39
				addLog('<<< : ' + e.data);
40
			}
41
			sock.onclose = function () {
42
				addLog('closed');
43
			}
44
		}
45
46
		function send(data) {
47
			sock && sock.send(data);
48
			addLog('>>> : ' + data);
49
		}
50
	</script>
51
52
	<button onclick="create();">Create SockJS</button>
53
	<button onclick="send('ping');">Send ping</button>
54
	<button onclick="sock && sock.close();">Close SockJS</button>
55
	<div id="log" style="width:300px; height: 300px; border: 1px solid #999999; overflow:auto;"></div>
56
</body>
57
</html>
58
59
<?php
60
61
    }
62
}
63