-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource-class-YnievesDotNet.FourStream.FourStream.html
224 lines (201 loc) · 14.7 KB
/
source-class-YnievesDotNet.FourStream.FourStream.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex">
<title>File FourStream.php | FourStream</title>
<link rel="stylesheet" href="resources/bootstrap.min.css?973e37a8502921d56bc02bb55321f45b072b6f71">
<link rel="stylesheet" href="resources/style.css?49f43d3208c5d7e33fa16d36107a345bf11cc00d">
</head>
<body>
<nav id="navigation" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a href="index.html" class="navbar-brand">FourStream</a>
</div>
<div class="collapse navbar-collapse">
<form id="search" class="navbar-form navbar-left" role="search">
<input type="hidden" name="cx" value="">
<input type="hidden" name="ie" value="UTF-8">
<div class="form-group">
<input type="text" name="q" class="search-query form-control" placeholder="Search">
</div>
</form>
<ul class="nav navbar-nav">
<li>
<span>Namespace</span> </li>
<li>
<span>Class</span> </li>
<li class="divider-vertical"></li>
<li>
<a href="-API-documentation.zip" title="Download documentation as ZIP archive"><span>Download</span></a>
</li>
</ul>
</div>
</div>
</nav>
<div id="left">
<div id="menu">
<div id="groups">
<h3>Namespaces</h3>
<ul>
<li>
<a href="namespace-YnievesDotNet.html">
YnievesDotNet<span></span>
</a>
<ul>
<li>
<a href="namespace-YnievesDotNet.FourStream.html">
FourStream<span></span>
</a>
<ul>
<li>
<a href="namespace-YnievesDotNet.FourStream.Command.html">
Command </a>
</li>
<li>
<a href="namespace-YnievesDotNet.FourStream.Events.html">
Events </a>
</li>
<li>
<a href="namespace-YnievesDotNet.FourStream.Facades.html">
Facades </a>
</li>
<li>
<a href="namespace-YnievesDotNet.FourStream.FourStream.html">
FourStream </a>
</li>
<li>
<a href="namespace-YnievesDotNet.FourStream.Handlers.html">
Handlers<span></span>
</a>
<ul>
<li>
<a href="namespace-YnievesDotNet.FourStream.Handlers.Events.html">
Events </a>
</li>
</ul></li>
<li>
<a href="namespace-YnievesDotNet.FourStream.Models.html">
Models </a>
</li>
<li>
<a href="namespace-YnievesDotNet.FourStream.Traits.html">
Traits </a>
</li>
</ul></li></ul></li>
</ul>
</div>
<div id="elements">
<h3>Classes</h3>
<ul>
<li><a href="class-YnievesDotNet.FourStream.Command.FourStreamStartCommand.html">YnievesDotNet\FourStream\Command\FourStreamStartCommand</a></li>
<li><a href="class-YnievesDotNet.FourStream.Events.BinaryMessageReceived.html">YnievesDotNet\FourStream\Events\BinaryMessageReceived</a></li>
<li><a href="class-YnievesDotNet.FourStream.Events.ConnectionClose.html">YnievesDotNet\FourStream\Events\ConnectionClose</a></li>
<li><a href="class-YnievesDotNet.FourStream.Events.ConnectionOpen.html">YnievesDotNet\FourStream\Events\ConnectionOpen</a></li>
<li><a href="class-YnievesDotNet.FourStream.Events.ErrorGenerated.html">YnievesDotNet\FourStream\Events\ErrorGenerated</a></li>
<li><a href="class-YnievesDotNet.FourStream.Events.MessageReceived.html">YnievesDotNet\FourStream\Events\MessageReceived</a></li>
<li><a href="class-YnievesDotNet.FourStream.Events.PingReceived.html">YnievesDotNet\FourStream\Events\PingReceived</a></li>
<li><a href="class-YnievesDotNet.FourStream.Facades.FourStream.html">YnievesDotNet\FourStream\Facades\FourStream</a></li>
<li><a href="class-YnievesDotNet.FourStream.FourStream.html">YnievesDotNet\FourStream\FourStream</a></li>
<li><a href="class-YnievesDotNet.FourStream.FourStream.FourStreamServer.html">YnievesDotNet\FourStream\FourStream\FourStreamServer</a></li>
<li><a href="class-YnievesDotNet.FourStream.FourStreamRouter.html">YnievesDotNet\FourStream\FourStreamRouter</a></li>
<li><a href="class-YnievesDotNet.FourStream.FourStreamServiceProvider.html">YnievesDotNet\FourStream\FourStreamServiceProvider</a></li>
<li><a href="class-YnievesDotNet.FourStream.Handlers.Events.BinaryMessageReceived.html">YnievesDotNet\FourStream\Handlers\Events\BinaryMessageReceived</a></li>
<li><a href="class-YnievesDotNet.FourStream.Handlers.Events.ConnectionClose.html">YnievesDotNet\FourStream\Handlers\Events\ConnectionClose</a></li>
<li><a href="class-YnievesDotNet.FourStream.Handlers.Events.ConnectionOpen.html">YnievesDotNet\FourStream\Handlers\Events\ConnectionOpen</a></li>
<li><a href="class-YnievesDotNet.FourStream.Handlers.Events.ErrorGenerated.html">YnievesDotNet\FourStream\Handlers\Events\ErrorGenerated</a></li>
<li><a href="class-YnievesDotNet.FourStream.Handlers.Events.MessageReceived.html">YnievesDotNet\FourStream\Handlers\Events\MessageReceived</a></li>
<li><a href="class-YnievesDotNet.FourStream.Handlers.Events.PingReceived.html">YnievesDotNet\FourStream\Handlers\Events\PingReceived</a></li>
<li><a href="class-YnievesDotNet.FourStream.Models.FourStreamNode.html">YnievesDotNet\FourStream\Models\FourStreamNode</a></li>
<li><a href="class-YnievesDotNet.FourStream.Models.FourStreamTag.html">YnievesDotNet\FourStream\Models\FourStreamTag</a></li>
</ul>
<h3>Traits</h3>
<ul>
<li><a href="class-YnievesDotNet.FourStream.Traits.FourStreamUserNodes.html">YnievesDotNet\FourStream\Traits\FourStreamUserNodes</a></li>
</ul>
</div>
</div>
</div>
<div id="splitter"></div>
<div id="right">
<div id="rightInner">
<pre id="source"><code><span id="1" class="l"><a href="#1"> 1 </a><span class="xlang"><?php</span>
</span><span id="2" class="l"><a href="#2"> 2 </a><span class="php-comment">/**
</span></span><span id="3" class="l"><a href="#3"> 3 </a><span class="php-comment"> * The MIT License (MIT)
</span></span><span id="4" class="l"><a href="#4"> 4 </a><span class="php-comment"> *
</span></span><span id="5" class="l"><a href="#5"> 5 </a><span class="php-comment"> * Copyright (c) 2007-2015 YnievesDotNet <yoinier.hn@gmail.com>
</span></span><span id="6" class="l"><a href="#6"> 6 </a><span class="php-comment"> *
</span></span><span id="7" class="l"><a href="#7"> 7 </a><span class="php-comment"> * Permission is hereby granted, free of charge, to any person obtaining a copy
</span></span><span id="8" class="l"><a href="#8"> 8 </a><span class="php-comment"> * of this software and associated documentation files (the "Software"), to deal
</span></span><span id="9" class="l"><a href="#9"> 9 </a><span class="php-comment"> * in the Software without restriction, including without limitation the rights
</span></span><span id="10" class="l"><a href="#10">10 </a><span class="php-comment"> * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
</span></span><span id="11" class="l"><a href="#11">11 </a><span class="php-comment"> * copies of the Software, and to permit persons to whom the Software is
</span></span><span id="12" class="l"><a href="#12">12 </a><span class="php-comment"> * furnished to do so, subject to the following conditions:
</span></span><span id="13" class="l"><a href="#13">13 </a><span class="php-comment"> *
</span></span><span id="14" class="l"><a href="#14">14 </a><span class="php-comment"> * The above copyright notice and this permission notice shall be included in
</span></span><span id="15" class="l"><a href="#15">15 </a><span class="php-comment"> * all copies or substantial portions of the Software.
</span></span><span id="16" class="l"><a href="#16">16 </a><span class="php-comment"> *
</span></span><span id="17" class="l"><a href="#17">17 </a><span class="php-comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
</span></span><span id="18" class="l"><a href="#18">18 </a><span class="php-comment"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
</span></span><span id="19" class="l"><a href="#19">19 </a><span class="php-comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
</span></span><span id="20" class="l"><a href="#20">20 </a><span class="php-comment"> * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
</span></span><span id="21" class="l"><a href="#21">21 </a><span class="php-comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
</span></span><span id="22" class="l"><a href="#22">22 </a><span class="php-comment"> * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
</span></span><span id="23" class="l"><a href="#23">23 </a><span class="php-comment"> * THE SOFTWARE.
</span></span><span id="24" class="l"><a href="#24">24 </a><span class="php-comment"> */</span>
</span><span id="25" class="l"><a href="#25">25 </a>
</span><span id="26" class="l"><a href="#26">26 </a><span class="php-keyword1">namespace</span> YnievesDotNet\FourStream;
</span><span id="27" class="l"><a href="#27">27 </a>
</span><span id="28" class="l"><a href="#28">28 </a><span class="php-keyword1">use</span> Hoa\Websocket\Client <span class="php-keyword1">as</span> WsClient;
</span><span id="29" class="l"><a href="#29">29 </a><span class="php-keyword1">use</span> Hoa\Socket\Client <span class="php-keyword1">as</span> SClient;
</span><span id="30" class="l"><a href="#30">30 </a><span class="php-keyword1">use</span> YnievesDotNet\FourStream\Models\FourStreamNode <span class="php-keyword1">as</span> FSNode;
</span><span id="31" class="l"><a href="#31">31 </a>
</span><span id="32" class="l"><a href="#32">32 </a><span class="php-comment">/**
</span></span><span id="33" class="l"><a href="#33">33 </a><span class="php-comment"> * Class FourStream
</span></span><span id="34" class="l"><a href="#34">34 </a><span class="php-comment"> * @package YnievesDotNet\FourStream
</span></span><span id="35" class="l"><a href="#35">35 </a><span class="php-comment"> */</span>
</span><span id="36" class="l"><a href="#36">36 </a><span class="php-keyword1">class</span> FourStream {
</span><span id="37" class="l"><a href="#37">37 </a> <span class="php-comment">/**
</span></span><span id="38" class="l"><a href="#38">38 </a><span class="php-comment"> * @param $type
</span></span><span id="39" class="l"><a href="#39">39 </a><span class="php-comment"> * @param $data
</span></span><span id="40" class="l"><a href="#40">40 </a><span class="php-comment"> * @param $id
</span></span><span id="41" class="l"><a href="#41">41 </a><span class="php-comment"> */</span>
</span><span id="42" class="l"><a href="#42">42 </a> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> sendUserID(<span class="php-var">$type</span>, <span class="php-var">$data</span>, <span class="php-var">$id</span>) {
</span><span id="43" class="l"><a href="#43">43 </a> <span class="php-var">$nodes</span> = FSNode::where(<span class="php-quote">"user_id"</span>, <span class="php-var">$id</span>)->get();
</span><span id="44" class="l"><a href="#44">44 </a> <span class="php-keyword1">foreach</span> (<span class="php-var">$nodes</span> <span class="php-keyword1">as</span> <span class="php-var">$node</span>) {
</span><span id="45" class="l"><a href="#45">45 </a> self::send(<span class="php-var">$type</span>, <span class="php-var">$data</span>, <span class="php-var">$node</span>->node_id);
</span><span id="46" class="l"><a href="#46">46 </a> }
</span><span id="47" class="l"><a href="#47">47 </a> }
</span><span id="48" class="l"><a href="#48">48 </a>
</span><span id="49" class="l"><a href="#49">49 </a> <span class="php-comment">/**
</span></span><span id="50" class="l"><a href="#50">50 </a><span class="php-comment"> * @param $type
</span></span><span id="51" class="l"><a href="#51">51 </a><span class="php-comment"> * @param $data
</span></span><span id="52" class="l"><a href="#52">52 </a><span class="php-comment"> * @param $node_id
</span></span><span id="53" class="l"><a href="#53">53 </a><span class="php-comment"> */</span>
</span><span id="54" class="l"><a href="#54">54 </a> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> send(<span class="php-var">$type</span>, <span class="php-var">$data</span>, <span class="php-var">$node_id</span> = <span class="php-keyword1">null</span>) {
</span><span id="55" class="l"><a href="#55">55 </a> <span class="php-var">$msg</span> = <span class="php-keyword1">array</span>(
</span><span id="56" class="l"><a href="#56">56 </a> <span class="php-quote">'type'</span> => <span class="php-var">$type</span>,
</span><span id="57" class="l"><a href="#57">57 </a> <span class="php-quote">'data'</span> => <span class="php-var">$data</span>,
</span><span id="58" class="l"><a href="#58">58 </a> <span class="php-quote">'node_id'</span> => <span class="php-var">$node_id</span>
</span><span id="59" class="l"><a href="#59">59 </a> );
</span><span id="60" class="l"><a href="#60">60 </a> <span class="php-var">$host</span> = config(<span class="php-quote">'fourstream.host'</span>);
</span><span id="61" class="l"><a href="#61">61 </a> <span class="php-var">$port</span> = config(<span class="php-quote">'fourstream.port'</span>);
</span><span id="62" class="l"><a href="#62">62 </a> <span class="php-var">$tcpid</span> = <span class="php-quote">"tcp://</span><span class="php-var">$host</span><span class="php-quote">:</span><span class="php-var">$port</span><span class="php-quote">"</span>;
</span><span id="63" class="l"><a href="#63">63 </a> <span class="php-var">$client</span> = <span class="php-keyword1">new</span> WsClient(
</span><span id="64" class="l"><a href="#64">64 </a> <span class="php-keyword1">new</span> SClient(<span class="php-var">$tcpid</span>)
</span><span id="65" class="l"><a href="#65">65 </a> );
</span><span id="66" class="l"><a href="#66">66 </a> <span class="php-var">$client</span>->connect();
</span><span id="67" class="l"><a href="#67">67 </a> <span class="php-var">$client</span>->send(<span class="php-keyword2">json_encode</span>(<span class="php-var">$msg</span>));
</span><span id="68" class="l"><a href="#68">68 </a> <span class="php-var">$client</span>->close();
</span><span id="69" class="l"><a href="#69">69 </a> }
</span><span id="70" class="l"><a href="#70">70 </a>}</span></code></pre>
</div>
<div id="footer">
FourStream API documentation generated by <a href="http://apigen.org">ApiGen</a>
</div>
</div>
<script src="resources/combined.js?533e23ef2f02bd4b20548834a028566b6eb403e0"></script>
<script src="elementlist.js?5a53130dea87ed1c135c563dcac56bcec3a4893e"></script>
</body>
</html>