@@ -63,13 +63,13 @@ $server->registerApplication('chat', \Bloatless\WebSocket\Examples\Application\C
63
63
$server->run();
64
64
```
65
65
66
- Assuming this code is in a file called ` server.php ` you can than start your server with the following command:
66
+ Assuming this code is in a file called ` server.php ` you can then start your server with the following command:
67
67
68
68
``` shell
69
69
php server.php
70
70
```
71
71
72
- The websocket server will than listen for new connection on the provided host and port. By default, this will be
72
+ The websocket server will then listen for new connections on the provided host and port. By default, this will be
73
73
` localhost:8000 ` .
74
74
75
75
This repositoy also includes a working example in [ examples/server.php] ( examples/server.php )
@@ -94,15 +94,15 @@ interface ApplicationInterface
94
94
}
95
95
```
96
96
97
- ` onConnet ` and ` onDisconnect ` can be used to keep track of all the clients connected to your application. ` onData ` will
98
- be called whenever the websocket server receives new data from one of the clients connect to the application.
97
+ ` onConnect ` and ` onDisconnect ` can be used to keep track of all the clients connected to your application. ` onData ` will
98
+ be called whenever the websocket server receives new data from one of the clients connected to the application.
99
99
` onIPCData ` will be called if data is provided by another process on your machine. (See [ Push-Client (IPC)] ( #push-client-ipc ) )
100
100
101
101
A working example of an application can be found in [ examples/Application/Chat.php] ( examples/Application/Chat.php )
102
102
103
103
### Timers
104
104
105
- A common requirement to long-running processes such as a websocket server is to execute tasks periodically. This can
105
+ A common requirement for long-running processes such as a websocket server is to execute tasks periodically. This can
106
106
be done using timers. Timers can execute methods within your server or application periodically. Here is an example:
107
107
108
108
``` php
@@ -119,12 +119,12 @@ This example would call the method `someMethod` within your chat application eve
119
119
### Push-Client (IPC)
120
120
121
121
It is often required to push data into the websocket-server process from another application. Let's assume you run a
122
- website containg a chat and an area containing news or a blog. Now every time a new article is published in your blog
122
+ website containing a chat and an area containing news or a blog. Now every time a new article is published in your blog
123
123
you want to notify all users currently in your chat. To achieve this you somehow need to push data from your blog
124
124
logic into the websocket server. This is where the Push-Client comes into play.
125
125
126
126
When starting the websocket server, it opens a unix-domain-socket and listens for new messages. The Push-Client can
127
- than be used to send these messages. Here is an example:
127
+ then be used to send these messages. Here is an example:
128
128
129
129
``` php
130
130
$pushClient = new \Bloatless\WebSocket\PushClient('//tmp/phpwss.sock');
@@ -134,17 +134,16 @@ $pushClient->sendToApplication('chat', [
134
134
]);
135
135
```
136
136
137
- This code pushes data into your running websocket-server process. In this case the ` echo ` Method within the
138
- chat-application is called and sends the provided message to all connected clients.
137
+ This code pushes data into your running websocket-server process. In this case the ` echo ` method within the
138
+ chat-application is called and it sends the provided message to all connected clients.
139
139
140
140
You can find the full working example in: [ examples/push.php] ( examples/push.php )
141
141
142
- ** Important Hint:** Push messages can be not larger than 64kb!
142
+ ** Important Hint:** Push messages cannot be larger than 64kb!
143
143
144
144
### Client (Browser/JS)
145
145
146
- Everything above this point was related to the server-side of things. But how to connect to the server from your
147
- browser?
146
+ Everything above this point was related to the server-side of things. But how to connect to the server from your browser?
148
147
149
148
Here is a simple example:
150
149
@@ -168,8 +167,8 @@ A better example of the chat client can be found in: [examples/public/chat.html]
168
167
169
168
## Intended use and limitations
170
169
171
- This project was mainly build for educational purposes. The code is relatively simple and easy to understand. This
172
- server was ** not tested in production** , so I strongly recommand to not use it on a live project. It should be totally
170
+ This project was mainly built for educational purposes. The code is relatively simple and easy to understand. This
171
+ server was ** not tested in production** , so I strongly recommend not to use it in a live project. It should be totally
173
172
fine for small educational projects or internal tools, but most probably will not handle huge amounts of traffic or
174
173
connections very well.
175
174
0 commit comments