Skip to content

Commit

Permalink
Merge pull request #1 from markphillips100/netcore
Browse files Browse the repository at this point in the history
Code parity with aspnetcore 3.1 typescript client, including auto-reconnect feature
  • Loading branch information
sefidgaran committed Nov 20, 2020
2 parents 39825dc + 6ef94a0 commit 956f242
Show file tree
Hide file tree
Showing 115 changed files with 3,580 additions and 2,694 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [0.1.8]
* Align codebase with AspNetCore 3.1 Typescript client codebase, including support for auto-reconnect

## [0.1.7+1]
* Minor changes

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

[![pub package](https://img.shields.io/pub/v/signalr_netcore.svg)](https://pub.dartlang.org/packages/signalr_netcore)

A Flutter SignalR Client for [ASP.NET Core](https://docs.microsoft.com/aspnet/core/signalr/?view=aspnetcore-2.1).
A Flutter SignalR Client for [ASP.NET Core 3.1](https://docs.microsoft.com/aspnet/core/signalr/?view=aspnetcore-3.1).
ASP.NET Core SignalR is an open-source library that simplifies adding real-time web functionality to apps. Real-time web functionality enables server-side code to push content to clients instantly.

The client is able to invoke server side hub functions (including streaming functions) and to receive method invocations issued by the server.
The client is able to invoke server side hub functions (including streaming functions) and to receive method invocations issued by the server. It also supports the auto-reconnect feature.

The client supports the following transport protocols:
* WebSocket
Expand All @@ -24,14 +24,14 @@ The client supports the following hub protocols:

## Getting Started

Add `signalr_client` to your `pubspec.yaml` dependencies:
Add `signalr_netcore` to your `pubspec.yaml` dependencies:
```yaml
...
dependencies:
flutter:
sdk: flutter

signalr_client:
signalr_netcore:
...
```

Expand All @@ -43,7 +43,7 @@ Let's demo some basic usages:
#### 1. Create a hub connection:
```dart
// Import the library.
import 'package:signalr_client/signalr_client.dart';
import 'package:signalr_netcore/signalr_client.dart';
// The location of the SignalR Server.
final serverUrl = "192.168.10.50:51001";
Expand All @@ -58,7 +58,7 @@ Logging is supported via the dart [logging package](https://pub.dartlang.org/pac
```dart
// Import theses libraries.
import 'package:logging/logging.dart';
import 'package:signalr_client/signalr_client.dart';
import 'package:signalr_netcore/signalr_client.dart';
// Configer the logging
Logger.root.level = Level.ALL;
Expand Down
2 changes: 1 addition & 1 deletion example/ChatServer/SignalRChatServer/ChatHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ChatHub : Hub
public void Send(string name, string message)
{
// Call the "OnMessage" method to update clients.
Clients.All.SendCoreAsync("OnMessage", new object[]{name, message});
Clients.All.SendAsync("OnMessage", name, message);
}

#endregion
Expand Down
18 changes: 11 additions & 7 deletions example/ChatServer/SignalRChatServer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace SignalRChatServer
{
public class Program
{
public static void Main(string[] args)
{
createWebHostBuilder(args).Build().Run();
CreateHostBuilder(args).Build().Run();
}

private static IWebHostBuilder createWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls(urls: "http://*:51002");
private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.UseStartup<Startup>()
.UseUrls(urls: "http://*:5000");
});
}
}
11 changes: 1 addition & 10 deletions example/ChatServer/SignalRChatServer/SignalRChatServer.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
</ItemGroup>

</Project>
24 changes: 8 additions & 16 deletions example/ChatServer/SignalRChatServer/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace SignalRChatServer
{
Expand All @@ -19,21 +18,11 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});


services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

services.AddSignalR();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
Expand All @@ -49,11 +38,14 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseSignalR(routes =>

app.UseRouting();

app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
routes.MapHub<ChatHub>("/Chat");
endpoints.MapHub<ChatHub>("/Chat");
});
app.UseMvc();
}
}
}
108 changes: 37 additions & 71 deletions example/chatclient/.gitignore
Original file line number Diff line number Diff line change
@@ -1,71 +1,37 @@
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Visual Studio Code related
.vscode/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/
build/

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
18 changes: 10 additions & 8 deletions example/chatclient/.metadata
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: f37c235c32fc15babe6dc7b7bc2ee4387e5ecf92
channel: beta
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 0b8abb4724aa590dd0f429683339b1e045a1594d
channel: stable

project_type: app
24 changes: 16 additions & 8 deletions example/chatclient/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# chatclient

A new Flutter project.

## Getting Started

For help getting started with Flutter, view our online
[documentation](https://flutter.io/).
# chatclient

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
7 changes: 7 additions & 0 deletions example/chatclient/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
Loading

0 comments on commit 956f242

Please sign in to comment.