我需要在Swift代码中包含JavaScript代码才能调用signalR聊天,这可能吗?如果没有,我可以转换它吗?
sendmessage 是一个按钮.
$(function () {
// Declare a proxy to reference the hub.
var chat = $.connection.chatHub;
// Create a function that the hub can call to broadcast messages.
chat.client.broadcastMessage = function (name, message) {
// some code
};
// Start the connection.
$.connection.hub.start().done(function () {
$('#sendmessage').click(function () {
// Call the Send method on the hub.
chat.server.send('name', 'message');
});
});
});
Run Code Online (Sandbox Code Playgroud)
而signalr代码是:
public void Send(string name, string message)
{
// Call the broadcastMessage method to update …Run Code Online (Sandbox Code Playgroud)