urho icon indicating copy to clipboard operation
urho copied to clipboard

Network events not working

Open xelamak opened this issue 8 years ago • 13 comments

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)
    }
    ...
}

xelamak avatar Jan 15 '17 11:01 xelamak

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

EgorBo avatar Jan 23 '17 07:01 EgorBo

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

xelamak avatar Jan 23 '17 08:01 xelamak

Is there any update ?

VBPrakash avatar Aug 07 '18 16:08 VBPrakash

@Egorbo

Hi Egorbo,

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

VBPrakash avatar Oct 15 '18 04:10 VBPrakash

+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!

barefists avatar Jan 01 '19 14:01 barefists

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

kevtsi avatar Mar 19 '19 17:03 kevtsi

+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?

CobraCalle avatar Apr 30 '19 10:04 CobraCalle

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

barefists avatar Apr 30 '19 14:04 barefists

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....

CobraCalle avatar Apr 30 '19 15:04 CobraCalle

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.

barefists avatar Apr 30 '19 15:04 barefists

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 avatar Dec 17 '20 12:12 gleblebedev

@barefists also does it work on mobile?

gleblebedev avatar Dec 17 '20 12:12 gleblebedev

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

barefists avatar Dec 17 '20 15:12 barefists