Coder Social home page Coder Social logo

signalr-samples's Introduction

This repo exists as an archived reference only. We are no longer taking changes or updating the code in this repo.

signalr-samples's People

Contributors

analogrelay avatar benaadams avatar bradygaster avatar brennanconroy avatar danmoseley avatar danroth27 avatar davidfowl avatar halter73 avatar mikaelm12 avatar moozzyk avatar paulochang avatar sgalcheung avatar terrajobst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

signalr-samples's Issues

Can not run signalR client below android 26

Exception Details
java.lang.ClassNotFoundException: Didn't find class "java.time.Duration" on path: DexPathList[[zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/base.apk", zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.microsoft.signalr.HubConnection.(HubConnection.java:50) 
at com.microsoft.signalr.HttpHubConnectionBuilder.build(HttpHubConnectionBuilder.java:64) 
at com.microsoft.aspnet.signalr.samples.androidjavaclient.MainActivity.onCreate(MainActivity.java:27) 
at android.app.Activity.performCreate(Activity.java:6876) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.microsoft.aspnet.signalr.samples.androidjavaclient-1/split_lib_slice_5_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:295)
at dalvik.system.DexFile.(DexFile.java:80)
at dalvik.system.DexFile.(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:279)
at dalvik.system.DexPathList.makePathElements(DexPathList.java:248)
at dalvik.system.DexPathList.(DexPathList.java:120)
at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.(PathClassLoader.java:65)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:84)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:45)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:434)
at android.app.LoadedApk.makeApplication(LoadedApk.java:659)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6289)

On Android api below 26 we are unable to run signalr client

Could you update to preview2?

ChatSample works, but if I update Microsoft.AspNetCore.All from preview1 to preview2, it doesn't work. So, could you provide an example using preview2?

Could not load assembly 'System.Memory, Version=4.0.1.0

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1590,2): error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Perhaps it doesn't exist in the Mono for Android profile?
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1590,2): error : File name: 'System.Memory.dll'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1590,2): error : at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1590,2): error : at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1590,2): error : at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)

Error java.lang.NoClassDefFoundError: com.microsoft.aspnet.signalr.-$$Lambda$CallbackMap$V5Uq2tEgd64-ZwWFXygwi8ZeV4I

I am facing below error at hubConnection.on("ReceiveMessage",..):
java.lang.NoClassDefFoundError: com.microsoft.aspnet.signalr.-$$Lambda$CallbackMap$V5Uq2tEgd64-ZwWFXygwi8ZeV4I

dependency

implementation 'com.microsoft.aspnet:signalr:0.1.0-preview1-35029'

here throwing that error

hubConnection.on("ReceiveMessage", (message)-> {

        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Log.d("MessageReceived",message);
                arrayAdapter.add(senderName + " : " +message);
                arrayAdapter.notifyDataSetChanged();
            }
        });
    }, String.class);

Find below error source

**10-07 23:24:39.425 18779-18779/com.cabieo.cabieoapp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.microsoft.aspnet.signalr.-$$Lambda$CallbackMap$V5Uq2tEgd64-ZwWFXygwi8ZeV4I>
10-07 23:24:39.425 18779-18779/com.cabieo.cabieoapp D/AndroidRuntime: Shutting down VM

--------- beginning of crash

10-07 23:24:39.600 18779-18779/com.cabieo.cabieoapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.cabieo.cabieoapp, PID: 18779
java.lang.NoClassDefFoundError: com.microsoft.aspnet.signalr.-$$Lambda$CallbackMap$V5Uq2tEgd64-ZwWFXygwi8ZeV4I
at com.microsoft.aspnet.signalr.CallbackMap.put(CallbackMap.java:15)
at com.microsoft.aspnet.signalr.HubConnection.on(HubConnection.java:219)
at com.cabieo.cabieoapp.Fragments.ChatHomeFragment.onCreateView(ChatHomeFragment.java:70)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
at android.os.Handler.handleCallback(Handler.java:742)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5571)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
10-07 23:24:39.607 5240-5310/? I/octvm_klo: klo lock**

Server side: OnDisconnectedAsync call occurs at different intervals when Wi-Fi is turned off.

Hello to all. Please help solve problem. I've issue with calling OnDisconnectedAsync method when IPad wi-fi turned off, calling may be happen fast but some times it takes a long time more 10 minutes, but some times never. I need a stable disconnect calling for example 30 seconds. I use signalR 1.1.0 with default KeepAliveInterval and ServerTimeout. How I can manage this?
I hope I don't have to do a manual check of the client to disconnect. It'll be terrible:(

Thx for help.

Signalr group keeps awaiting if client closes app.

I have a signalr implementation of a server which allows users to connect to multiple groups. I am using the WPF .NET signalr client to connect and have noticed, very regularly, that if the client closes the application abruptly, with invoking disconnect, the server signalr group keeps waiting on rude send method. This can be replicated easily by creating a high throughout server using Groups and the call hangs on
await _hunContext.Clients.Group(groups).SendMsg(msg).
I will appreciate any help since I haven’t noticed any samples which utilizes groups.

OkHttp Dispatcher

06-11 08:55:03.470 14490-2778/com.tatweer.vehicledashboardapp.dev E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com.tatweer.vehicledashboardapp.dev, PID: 14490
java.lang.StackOverflowError: stack size 1038KB
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(SingleFlatMapCompletable.java:102)
at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onComplete(Single

android 6
retrofitVersion = '2.3.0'
rxVersion = '2.1.1'
rxAndroidVersion = '2.0.2'
implementation "com.squareup.retrofit2:adapter-rxjava2:$rootProject.retrofitVersion"
implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
implementation "io.reactivex.rxjava2:rxjava:$rootProject.rxVersion"
implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxAndroidVersion"
implementation "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"

Uncaught TypeError in ChatSample

Using Windows 7, latest Chrome, latest SDK; preview-2

Pulled it down via github, ran as is. However, "url" should be replaced with "/chat" in index.html.

(index):55 Uncaught TypeError: Cannot read property 'invoke' of undefined
at HTMLInputElement. ((index):55)

at line
connection.invoke('send', name, messageInput.value);

can't Run this sample

if for this samples,error is follow:
System.Net.WebSockets.WebSocketException: The 'Sec-WebSocket-Accept' header value 'TTADvdCKZ4RHl0ek4ZWlOMVlq0I=' is invalid.
if add .WithTransport(Microsoft.AspNetCore.Sockets.TransportType.LongPolling), then error is follow:
System.Net.Http.HttpRequestException: 500 (Internal Server Error)
if add .WithTransport(Microsoft.AspNetCore.Sockets.TransportType.ServerSentEvents), then error is follow:
System.Threading.Tasks.TaskCanceledException: A task was canceled.
if add .WithTransport(Microsoft.AspNetCore.Sockets.TransportType.ServerSentEvents), then error is follow:
if add WebSockets then error is follow:
System.Net.WebSockets.WebSocketException: The 'Sec-WebSocket-Accept' header value 'M4b91cosiaTsNqwMqG1/Pv7WICw=' is invalid.

Unable to connect with SignalR with any available transports. Error 404 "No Connection with that ID"

Problem

I have a react website in which I am trying to connect to SignalR hub on my .net core server via ocelot gateway.

I am unable to connect to hub and get a 404 error "No Connection with that ID". I have only one server instance running and no load balancer is involved.
SignalR  Hub request
Hub Call response

Even though the negotiate call is always successful.
Negotiate Response

WebSocket and Server Sent Events are not working at all and on Long Polling, 404 is returned.
Console logs

Network call logs are:
Network logs

I have added all possible routes for ocelot. I am out of ideas on what to do now.
SignalR Ocelot Routes

I have observed that the connectionId returned in response to the negotiate call is not used to connect to hub and instead the connectionToken value is used as the value for "id" query string parameter.

Specifications

  • Ocelot Version: 15.0.6
  • @microsoft/signalr Version: 5.0.1
  • .Net Core: 3.1
  • Platform: Windows

Chat Samle not work!

        connection.start()
            .then(function (connection) {
                console.log(connection);

connection started, ok. but after that
here connection is undefined and of course all other not work

not able to navigate to route

Hi All,
ChatSample is working fine on my machine but the only thing is when I am trying to refer full url i.e "http://localhost:64654/chat" then I am getting error. The error says "Connection ID required" so is it a bug or I am not doing something wrong.Help me out

SignalR .Net Core 3.1 unable to send object in SendAsync method from service class

Previously I was using .Net Core 2.2, I was able to send a json object from a service class using hub context and SendAsync method to a front end web client. Im having issues after I've upgraded my project framework to 3.1. If i call the SendAsync method using a json object, it will hit an error stating "{"The collection type 'Newtonsoft.Json.Linq.JObject' is not supported."}", if I send any other class object it will directly go to OnDisconnected.

Sample of the method i use

Using Json Object: await _hubContext.Clients.Group(groupName).SendAsync("NotificationResponse", jsonObject);

Using Class Object: await _hubContext.Clients.Group(groupName).SendAsync("NotificationResponse", notificationObject);

I've tried sending object directly from the hub, I was able to send a normal class object but not a json object. I did the testing on my project and also sample from this tutorial: https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr?view=aspnetcore-3.1&tabs=visual-studio

Authorisation

would please add bearer token authentication sample

Error 204 received

I received error:
WebSocket connection to 'ws://localhost:2052/chat?id=cac62362-90af-49e9-ad97-59eecaadfee8' failed: Error during WebSocket handshake: Unexpected response code: 204

Include Java Maven project?

There's currently an Android project with gradle that uses the Java client but I think we should also include a simple Java console application the uses Maven.

CSharpClient Not Working

I can run the StockTickRApp and connect the NodeClient and see stock prices written to the console. When I connect the CSharpClient it does not write anything to the console.

From debugging I suspect this section:

var state = await connection.InvokeAsync<string>("GetMarketState");
if (string.Equals(state, "Open"))

The call to GetMarketState returns "Closed" so the StartStreaming method is never called.

HubConnection not trigger registering methods in Android.

When I try to use your sample code and start hubConnection in AsynTask send method works but on method does not work.

public class ChatActivity extends BaseActivity {

public HubConnection hubConnection;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);

    String bearerToken = localStorage.getString("KEY_AUTHORIZATION_TOKEN");

    hubConnection = HubConnectionBuilder.create("https://....")
            .withHeader("Authorization", bearerToken)
            .build();

    hubConnection.on("DeletedChat", chatModel -> {
        EventBus.getDefault().post(new DeletedChatEvent(chatModel));
    }, ChatModel.class);

    hubConnection.on("NewChat", chatModel -> {
        EventBus.getDefault().post(new NewChatEvent(chatModel));
    }, ChatModel.class);

    hubConnection.on("NewMessage", chatMessageModel -> {
        EventBus.getDefault().post(new NewMessageEvent(chatMessageModel));
    }, ChatMessageModel.class);

    hubConnection.on("ReadedMessages", chatMessageModels -> {
        EventBus.getDefault().post(new ReadedMessagesEvent(chatMessageModels));
    }, ChatMessageModel[].class);

    new HubConnectionTask().execute(hubConnection);
}

public void sendMessage(ChatModel chatModel){
    hubConnection.send("SendMessage", chatModel);
}

class HubConnectionTask extends AsyncTask<HubConnection, Void, Void> {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected Void doInBackground(HubConnection... hubConnections) {
        HubConnection hubConnection = hubConnections[0];
        hubConnection.start().blockingAwait();
        return null;
    }
}

}

If I try to connect hubConnection in onCreate() without AsyncTask as below everything work fine but .blockingAwait() is blocking main thread and activity does not open for a while.

public class ChatActivity extends BaseActivity {

public HubConnection hubConnection;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);

    String bearerToken = localStorage.getString("KEY_AUTHORIZATION_TOKEN");

    hubConnection = HubConnectionBuilder.create("https://...")
            .withHeader("Authorization", bearerToken)
            .build();

    hubConnection.on("DeletedChat", chatModel -> {
        EventBus.getDefault().post(new DeletedChatEvent(chatModel));
    }, ChatModel.class);

    hubConnection.on("NewChat", chatModel -> {
        EventBus.getDefault().post(new NewChatEvent(chatModel));
    }, ChatModel.class);

    hubConnection.on("NewMessage", chatMessageModel -> {
        EventBus.getDefault().post(new NewMessageEvent(chatMessageModel));
    }, ChatMessageModel.class);

    hubConnection.on("ReadedMessages", chatMessageModels -> {
        EventBus.getDefault().post(new ReadedMessagesEvent(chatMessageModels));
    }, ChatMessageModel[].class);

    hubConnection.start().blockingAwait();
}

public void sendMessage(ChatModel chatModel){
    hubConnection.send("SendMessage", chatModel);
}

}

If I trying to connection just with hubConnection.start(); , send methods work but on methods not working again.

public class ChatActivity extends BaseActivity {

public HubConnection hubConnection;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);

    String bearerToken = localStorage.getString("KEY_AUTHORIZATION_TOKEN");

    hubConnection = HubConnectionBuilder.create("https://...")
            .withHeader("Authorization", bearerToken)
            .build();

    hubConnection.on("DeletedChat", chatModel -> {
        EventBus.getDefault().post(new DeletedChatEvent(chatModel));
    }, ChatModel.class);

    hubConnection.on("NewChat", chatModel -> {
        EventBus.getDefault().post(new NewChatEvent(chatModel));
    }, ChatModel.class);

    hubConnection.on("NewMessage", chatMessageModel -> {
        EventBus.getDefault().post(new NewMessageEvent(chatMessageModel));
    }, ChatMessageModel.class);

    hubConnection.on("ReadedMessages", chatMessageModels -> {
        EventBus.getDefault().post(new ReadedMessagesEvent(chatMessageModels));
    }, ChatMessageModel[].class);

    hubConnection.start();
}

public void sendMessage(ChatModel chatModel){
    hubConnection.send("SendMessage", chatModel);
}

}

How can we start activity and make the on methods work without locking the main thread?

Show .NET Core Server Example

I want to run a SignalR .NET Core server without an ASP.NET website backing it (like the self-host examples of the old SignalR).

It'd be nice to see an example here of how to do this?

Nodejs client does not work

I created a basic example based on the sample , however it does not work

const signalR = require("@aspnet/signalr");

XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
WebSocket = require("websocket").w3cwebsocket;
 
let connection = new signalR.HubConnectionBuilder()
    .withUrl("http://localhost:61937/signalr/hubs")
    .build();
 
connection.on("send", data => {
    console.log(data);
});
 
connection.start()
    .then(() => connection.invoke("send", "Hello"));

error -


module.js:549
    throw err;
    ^

Error: Cannot find module 'tslib'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (..../signarlclient/node_modules/@aspnet/signalr/dist/cjs/Errors.js:5:15)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

node environment

node -v
v10.8.0
npm -v
6.2.0

packages installed

  "dependencies": {
    "@aspnet/signalr": "^1.0.3",
    "@types/node": "^10.9.4",
    "eventsource": "^1.0.7",
    "websocket": "^1.0.26",
    "xmlhttprequest": "^1.8.0"
  }

There were no compatible transports on the server.

How to fix the below error from hubConnection.start().blockingAwait();

Caused by: java.lang.RuntimeException: There were no compatible transports on the server.
at com.microsoft.signalr.HubConnection.lambda$startNegotiate$11(HubConnection.java:364)
at com.microsoft.signalr.-$$Lambda$HubConnection$GiLlPVdlbvryuPaYB9UmGffcsYc.apply(Unknown Source:8)
at io.reactivex.internal.operators.single.SingleFlatMap$SingleFlatMapCallback.onSuccess(SingleFlatMap.java:76)
at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:64)
at io.reactivex.subjects.SingleSubject.onSuccess(SingleSubject.java:141)
at com.microsoft.signalr.DefaultHttpClient$2.onResponse(DefaultHttpClient.java:124)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)

Build ASP.NET Core 3.x SignalR with real-time database notification SqlDependency

Can someone share a project example of a MVC web application implementing real-time database notification with using ASP.NET Core 3.0 or 3.1, ADO.NET, SignalR 3.0 and SqlDependency ?
I am building a dashboard web application ASP.NET Core 3.1 that has a grid in which real-time data gets updated/inserted/deleted by multiple concurrent users. I found a few examples but they are for ASP.NET Core 2.x and not complete project examples. I don't know how I should be implementing the SignalR and SqlDependency pieces the "proper" way in my project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.