I am using XSocket.Net for Real time Communication in .Net version 4.5.
I am very new to XSocket.Net.
The following is what i tried. In the Controller folder I created MyController with following code.
using System;
using XSockets.Core.XSocket;
using XSockets.Core.XSocket.Helpers;
namespace XSocketTest.Controllers
{
public class MyController : XSocketController
{
public void OnChatMessage(string message)
{
this.SendTo( message, "onChatMessage");
}
}
}
The Following is the html page "index.html" in the root location
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<input type="text" id="input-message" value="Goo LR" />
<button id="btn-send">send</button>
<div id="messages"></div>
<script src="Scripts/jquery-2.1.0.min.js"></script>
<script src="Scripts/XSockets.latest.js"></script>
<script>
var conn = null;
$(function () {
//Create a connection
conn = new XSockets.WebSocket('ws://localhost:4023/My');
conn.onopen = function () {
conn.on('onchatmessage', function (d) {
$('#messages').prepend($('<div>').text(d));
});
};
$('#btn-send').on('click', function () {
conn.publish('onchatmessage', { message: $('#input-message').val() });
});
});
</script>
</body>
</html>
I am getting an error in console(Chrome), on loading html, "WebSocket connection to 'ws://localhost:4023/My' failed: Error during WebSocket handshake: Unexpected response code: 404"
I have no idea what I am doing wrong.
Any help or sugggestions will be greatly appreciated.