-
-
Save polatengin/1ec1f103e04cce2ef6bb865f3a90d30c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Asp.Net Core üzerinde SignalR kullanımı |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.SignalR; | |
namespace ConsoleApplication | |
{ | |
public class ChatHub : Hub | |
{ | |
public void Send(string message) | |
{ | |
Clients.All.display(message); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<body> | |
<textarea id="chatArea" cols="50" rows="20"></textarea> | |
<br /><br /> | |
<input id="message" type="text" /> | |
<input id="send" type="button" value="Gonder" /> | |
<script src="http://code.jquery.com/jquery-2.2.4.js"></script> | |
<script src="http://ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-2.0.3.js"></script> | |
<script src="/signalr/js"></script> | |
<script> | |
var hub = $.connection.chatHub; | |
hub.client.display = function(received) { | |
chatArea.value += received + ‘\n’; | |
}; | |
send.addEventListener(‘click’, function() { | |
hub.server.send(message.value); | |
}); | |
$.connection.hub.start(); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"> | |
<configuration> | |
<packageSources> | |
<clear /> | |
<add key="aspnetcidev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" /> | |
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" /> | |
</packageSources> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Main(string[] args) | |
{ | |
var host = new WebHostBuilder() | |
.UseKestrel() | |
.UseContentRoot(Directory.GetCurrentDirectory() + "/wwwroot") | |
.UseStartup<Startup>() | |
.Build(); | |
host.Run(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using Microsoft.AspNetCore.Hosting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies": { | |
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", | |
"Microsoft.AspNetCore.StaticFiles": "1.1.0-*", | |
"Microsoft.AspNetCore.SignalR.Server": "0.2.0-*", | |
"Microsoft.AspNetCore.WebSockets": "0.2.0-*" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.FileProviders; | |
namespace ConsoleApplication | |
{ | |
public class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddSignalR(); | |
} | |
public void Configure(IApplicationBuilder app) | |
{ | |
app.UseStaticFiles(new StaticFileOptions() | |
{ | |
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory() + "/wwwroot")), | |
RequestPath = new PathString("") | |
}); | |
app.UseWebSockets(); | |
app.UseSignalR(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment