#NetworkClient.Send method disconnect client

1 messages · Page 1 of 1 (latest)

fallen widget
#

Hello, i am in need of answers for some questions regarding mirror's use 😅
I must be doing something wrong but I don't identify what.
I have two devices that should communicate. One is an android phone, and will act as the server.
Others will be oculus quest and will act as clients.

What is working :
Server start.
Client's network discovery works.
Client connect to server successfully.

But the instant I try to execute
NetworkClient.send(myStructMessage) the client disconnect. (Without errors or log)

Now I have two constraints :

  1. this is two separate unity projects for server and client. (I spend two hours searching and finally finding that hidden secretHandshake variable that I had to set identically to both projects)

  2. the network related code cannot be identical, as there is some very project specific assets and code running differently on both side

What I'm simply trying to achieve is to send some device infos ( ID, battery, string) from the client to the server, and the server to send simply a boolean to one client.
(All of this is in LAN)

I'm using a struct inheriting from networkmessage, of course it's definition is identical in the server and client.

Is there a chance I will get it to work without rewriting a lot of stuff ?

Thanks in advance !

mental swift
fallen widget
#

I tried to use that method but I cannot use
NetworkServer.RegisterHandler<myMsgStruct>(MyCallFunction);

I am getting an error at compilation "cannot convert from 'method group' to 'Action<NetworkConnectToClient, myScript.myMsgStruct>'

fallen widget
#

Okay,got it to work.

What I had to do :

  • inherit my script from networkmanager.
  • add "networkconnectiontoclient var into my handling function (even if I never intend to use it)
  • override OnServerStart function
  • create a secondary script that have a call to networkManager.StartServer function in the unity start function, because otherwhile I don't know why but my script now totally ignore the start function

That's a lot of things just to send two strings over the air 😔

mental swift
#

Server message handlers always need the networkconnectiontoclient param, whether you use it or not...that's how they're wired up. It's the only way for you to know which connection the msg came from.

#

Regardless, phones make terrible servers, and having separate projects is just making everything harder and more fragile for no actual gain.