Comments (6)
Yes, it works!
But you did not connect to your Hub. You only do this if you set up listener for that hub before calling connection.start. And lifecycle-events are only handled on the hub itself.
Strange indeed!
Nonetheless, thank you so much for the support!
FYI, when I did a npm install for signalr, the package.json still indicates 0.0.10.
from react-native-signalr.
Post some sample js-code here please. (I have used OnConnected with this library before and it should work).
And please update to react-native-signalr : 1.0.0
from react-native-signalr.
The code as below:
`connection = signalr.hubConnection(socketUrl); connection.logging = true;
proxy = connection.createHubProxy(Constant.PROXY_HUB);
return (dispatch) => {
connection.start().done(() => {
Reactotron.log('Now connected, connection ID=' + connection.id);
dispatch({
type: ActionTypes.ESTABLISH_CONNECTION_SUCCESS,
payload: {
Activity: ActionTypes.ESTABLISH_CONNECTION_SUCCESS,
ConnectionId: connection.id
}
});
// Connection-handling
connection.connectionSlow(function () {
Reactotron.log('Connection slow');
dispatch({
type: ActionTypes.CONNECTION_SLOW,
payload: {
Activity: ActionTypes.CONNECTION_SLOW
}
});
});
connection.reconnecting(function () {
Reactotron.log('Connection reconnecting');
});
connection.reconnected(function () {
Reactotron.log('Connection reconnected');
});
connection.disconnected(function () {
Reactotron.log('Connection disconnected');
});
connection.error(function (error) {
Reactotron.log('Connection error');
dispatch({
type: ActionTypes.CONNECTION_HAS_ERROR,
payload: {
Activity: ActionTypes.CONNECTION_HAS_ERROR,
Error: error
}
});
});
}).fail((error) => {
Reactotron.log('Connection failed');
Reactotron.log(error);
dispatch({
type: ActionTypes.ESTABLISH_CONNECTION_FAIL,
payload: {
Activity: ActionTypes.ESTABLISH_CONNECTION_FAIL,
}
});
});
dispatch({
type: ActionTypes.ESTABLISH_CONNECTION_REQUEST,
payload: {
Activity: ActionTypes.ESTABLISH_CONNECTION_REQUEST
}
});
};`
I gotten the connection id so I doubt there is problem with the code.
Let me try updating the version to 1.0.0 and get back to you.
Thanks for the fast response!
from react-native-signalr.
Hi,
There is still issue with the server method not being called, even though i had upgraded to 1.0.0
from react-native-signalr.
It works here if I add a listener to the hub.
Tested on example project and it works.
I think you need to do this in signalr.
proxy = connection.createHubProxy(Constant.PROXY_HUB);
proxy.on('someMethodTheHubMightCallYouOn', (argOne) => {
//I think you have to listen to a hub-method for lifecycle-events to fire on that hub.
//Please read signalr-docs.
});
return (dispatch) => {
connection.start().done(() => {
Reactotron.log('Now connected, connection ID=' + connection.id);
dispatch({
type: ActionTypes.ESTABLISH_CONNECTION_SUCCESS,
payload: {
Activity: ActionTypes.ESTABLISH_CONNECTION_SUCCESS,
ConnectionId: connection.id
}
});
// Connection-handling
connection.connectionSlow(function () {
Reactotron.log('Connection slow');
dispatch({
type: ActionTypes.CONNECTION_SLOW,
payload: {
Activity: ActionTypes.CONNECTION_SLOW
}
});
});
connection.reconnecting(function () {
Reactotron.log('Connection reconnecting');
});
connection.reconnected(function () {
Reactotron.log('Connection reconnected');
});
connection.disconnected(function () {
Reactotron.log('Connection disconnected');
});
connection.error(function (error) {
Reactotron.log('Connection error');
dispatch({
type: ActionTypes.CONNECTION_HAS_ERROR,
payload: {
Activity: ActionTypes.CONNECTION_HAS_ERROR,
Error: error
}
});
});
}).fail((error) => {
Reactotron.log('Connection failed');
Reactotron.log(error);
dispatch({
type: ActionTypes.ESTABLISH_CONNECTION_FAIL,
payload: {
Activity: ActionTypes.ESTABLISH_CONNECTION_FAIL,
}
});
});
dispatch({
type: ActionTypes.ESTABLISH_CONNECTION_REQUEST,
payload: {
Activity: ActionTypes.ESTABLISH_CONNECTION_REQUEST
}
});
};
from react-native-signalr.
My explanation for this: SignalR is a bit strange here. You established a successful connection to the server by calling connection.start().
But you did not connect to your Hub. You only do this if you set up a listener for that hub before calling connection.start. And lifecycle-events are only handled on the hub itself.
from react-native-signalr.
Related Issues (20)
- how can change state from on(event) HOT 1
- .NET core 2.0 support
- How is reconnection handled? HOT 3
- IOS - SignalR Connection break when app move in background. HOT 4
- Does it support Net Core 2.1 or later?
- get 'undefined' from server in invoke
- cannot receive message HOT 1
- Timer Error HOT 1
- Try specifying a different transport or none at all for auto initialization.
- How to send token or other data HOT 3
- Signal R not working with ANDROID STORE VERSION
- Unable to call signalR method
- Replace deprecated dependency ms-signalr-client HOT 1
- Failed - Error: Error during negotiation request. HOT 3
- Autoreconnect feature HOT 1
- TypeError: Cannot set property userAgent of #<Navigator> which has only a getter HOT 1
- hello
- Forgotten Package
- On Screen Change, Event Is Still fired HOT 7
- is this lib dead? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-signalr.