WebSocket is now connecting

This commit is contained in:
Frank A. Krueger 2017-06-12 18:50:48 -07:00
parent e6288e4ca7
commit a6e19e7923
2 changed files with 14 additions and 2 deletions

View File

@ -1,4 +1,16 @@
// Create WebSocket connection.
const socket = new WebSocket ("ws://localhost:8080", "ooui-1.0");
alert("Hello"); console.log("Socket created");
// Connection opened
socket.addEventListener('open', function (event) {
console.log("Socket opened");
socket.send('Hello Server!');
});
// Listen for messages
socket.addEventListener('message', function (event) {
console.log('Message from server', event.data);
});

View File

@ -119,7 +119,7 @@ namespace Ooui
{ {
WebSocketContext webSocketContext = null; WebSocketContext webSocketContext = null;
try { try {
webSocketContext = await listenerContext.AcceptWebSocketAsync(subProtocol: null).ConfigureAwait (false); webSocketContext = await listenerContext.AcceptWebSocketAsync(subProtocol: "ooui-1.0").ConfigureAwait (false);
Console.WriteLine ("Accepted WebSocket: {0}", webSocketContext); Console.WriteLine ("Accepted WebSocket: {0}", webSocketContext);
} }
catch (Exception e) { catch (Exception e) {