xamarin / urho

Code to integrate with the Urho3D engine
Other
463 stars 122 forks source link

Network events not working #180

Open xelamak opened 7 years ago

xelamak commented 7 years ago

Hello developers,

Currently on UrhoSharp 1.2.21 Network Events are not working as expected. I have tested the Chat Sample on both UrhoSharp and latest Urho3D from master branch, and here are the results:

Server Client Connect Send Message
Urho3D 2xUrhoSharp & 1xUrho3D Successful Urho3D Working normally, UrhoSharp can send but won't receive any messages
UrhoSharp 1xUrhoSharp & 2xUrho3D Successful Both UrhoSharp&Urho3D not working, pressing send can clear the text but nothing appears in chat history

The result leads me to a guess that Network events subscription on UrhoSharp are not working, I have created a simple application and subscribed to several network events. And here are the results:

Event Result (Client) Result (Server)
NetworkMessage The event handler was not called when client sent message to server The event handler was not called when server sent message to client
ClientConnected Not applicable Console displays client connected message correctly, but the user event handler was not called
ClientDisconnected Not applicable Console displays client disconnected message correctly, but the user event handler was not called
ConnectFailed Not tested Not tested
NetworkSceneLoadFailed Not tested Not tested
NetworkUpdate Called frequently (Every frame? Not sure, but the function was called continuously) Same as Client
NetworkUpdateSent Handler called after every NetworkUpdate Same as client
ServerConnected Event Handler called on connected to server Not applicable
ServerDisconnected Event Handler called on disconnected from server Not applicable

Example code of subscribing to NetworkMessage:

public class Server : Application {
    ...
    protected override void Setup(){
        base.Setup();
        Network.NetworkMessage += (arg) => {
            Urho.IO.Log.Write(LogLevel.Debug, "Network Message");
        };

        ... (subscribe to other events)
    }
    ...
}
EgorBo commented 7 years ago

@xelamak thanks for the detailed bug report, I am investigating...

xelamak commented 7 years ago

Thanks, I have also tried building UrhoSharp with latest Urho3D source myself but the problem still exists.

VBPrakash commented 6 years ago

Is there any update ?

VBPrakash commented 6 years ago

@Egorbo

Hi Egorbo,

Is there any scheduled plan to fix the network events issue ? Is there any work around to solve the problem.

barefists commented 5 years ago

+1 to this. I'm sending messages but not receiving any via the NetworkMessage event. I'm using an alternative networking library for the moment, please let us know if there are any updates!

kevtsi commented 5 years ago

+1 - Confirmed on 1.9.67. I cannot get NetworkMessage, ClientSceneLoaded, ClientDisconnected to fire using SubscribeToEvent or event handler syntax (Network.NetworkMessage += (arg) => {};).

CobraCalle commented 5 years ago

+1 - ClientConnected is nor called, so it is not possible to assign der scene on the server-side

Has anyone found a workaround for this?

barefists commented 5 years ago

For anyone this is troubling, I'm using an alternative networking library called LiteNetLib at the moment, works well with Urhosharp.

CobraCalle commented 5 years ago

Can you give me a hit, how to tell Urho to use LiteNetLib? Becouse I want to do Scene Replication, so I need the ClientConnected-Event to set the scene that soulf be replicated....

barefists commented 5 years ago

I don't think there's an automated way of doing it, you'll need serialize the scene into json or xml, send it over the network, then parse it on the other end.

gleblebedev commented 3 years ago

For anyone this is troubling, I'm using an alternative networking library called LiteNetLib at the moment, works well with Urhosharp.

Do you have any LiteNetLib UrhoSharp project published as open source?

gleblebedev commented 3 years ago

@barefists also does it work on mobile?

barefists commented 3 years ago

Yes it works on mobile - I don't have any open source project I can share right now with working code, unfortunately.