Search Unity

Question CustomMessagingManager.SendNamedMessage only works on first connected client

Discussion in 'Multiplayer' started by Creative-House-org, Aug 28, 2021.

  1. Creative-House-org

    Creative-House-org

    Joined:
    Nov 13, 2015
    Posts:
    4
    Hi

    I am currently working on two different projects (one for a server and one for a client).

    Now connecting to the server with the first client (which is the unity editor and which gets recognized as clientId #2) the messages which I send through SendNamedMessage gets received by the server Handler which I am registering with

    Code (CSharp):
    1. MLAPI.Messaging.CustomMessagingManager.RegisterNamedMessageHandler
    But now as soon as I start up the second client (which I've built as an exe and which gets recognized as clientId #3) the SendNamedMessage calls are then getting ignored by the server allthough I can see the OnClientConnected and the OnClientDisconnected event listeners from the NetworkManager are getting called when I start or exit the second client. So the second client should be connected to the server.

    Now if I exit both clients and starting up again the second client (the exe that I've built which was clientId 3) it gets recognized as client #2 which in my case is the first client and the messages are again received by the server handlers.

    Now my Question is as follows: Is the message which I'm sending getting ignored because I am using two clients on one machine or frankly said one operating system? And if not is there something else that I'm totally not aware of? As stated I am using multiple projects and I'm not using any NetworkPrefabs only the CustomMessagingManager.

    Any input on this would be great since I'm trying to get this to work for a few days now and googling was not so useful (or I just was searching with the wrong keywords)

    Thanks in advance
     
    Last edited: Aug 28, 2021
  2. bewise_studios

    bewise_studios

    Joined:
    Oct 3, 2016
    Posts:
    3
    Hi, I have the same problem. First client OK, but second client not working :/. I am trying to understand what's wrong, but no idea so far.
     
  3. bewise_studios

    bewise_studios

    Joined:
    Oct 3, 2016
    Posts:
    3
    Hi, so here is the problem. From documentation I thought clientId should be LocalClientId, but no, it should be receiver clientId, in my case ServerClientId.
    Example: CustomMessagingManager.SendNamedMessage("NameMessageId", NetworkManager.ServerClientId);