PHP WebSocket with protocol: JSONsvc

usernames listed here when using JSONsvc and 'Log Decoded'
If the php script is on a web server
then enter the url here:



e.g. "http://localhost:8080/wsdemo/websocket2.php"
or    "http://192.164.0.42/wsdemo/websocket2.php"
Start/stop the script (see this page source for how)
else: Websocket Host should provide the url/ip address and port number... Sends 'killserver' command to server
 
Websocket Host: Server Status:Closed
Connect for protocol:   If JSONsvc, set log:
 
Username: enter any name here
Message:    or: 

Debug:

Help...

This is a demo of websocket2.php - a WebSocket server written in PHP. The server can handle different protocols (Sec-WebSocket-Protocol), these are not standards but are application-specific.

In this case the server has the following protocols available:
'echo'-simply echos all input to ALL clients (including the sender)
'chat' - echos input to all clients using 'chat' protocol (except the sender)
'command' - responds to commands: 'data', 'time' and 'status' (to sender only)
'JSONsvc' - a prototype JSON-format data distribution service.

You can pick a protocol and send a message.

The JSONsvc is intended as a general-purpose data handler for multiple users - giving the impression of peer-to-peer connections.
Enter a username, click JSONsvc and send a message - you'll see the raw transport JSON.
now click the Log Decoded button, open another browser and pretend to be another user.

The 'decoded' view is how an application would use JSONsvc - a user requests data services and the server delivers those services to all registered clients. This means that messages are sent to users automatically when any other user sends a message, joins or leaves the group. Try changing username and send another message.

For debug, if your message starts with a '{' character it is sent raw to the JSONsvc - allowing you to enter raw JSON to test the server. For example:
{"from":"Bob","put":"text"}>this is a test
You can direcly request services like:
{"from":"Bob","get":["JSONsvc_Version","JSONsvc_Providers"]}
If you open more than one browser and set usernames to "Bob" and "Alice"...
 Bob send:   {"from":"Bob","provides":"BobService"}
 Alice send: {"from":"Alice","requests":"BobService"}
 
 Bob send:   {"from":"Bob","put":"BobService"}>This is Bob's service.
 Alice receives: {"from":"Bob","put":"BobService","to":"Alice"}>This is Bob's service.
  
Note: whenever you send a request, the "from" value sets the current name of your connection.