Publishing a session Locally

Is there a way of sending ip4v address on a local server? so that if someone is trying to connect they dont need to type in the server's ip address to connect, Im using BoltInit.cs. I've tried the BoltNetwork.sessionList thats used in BoltPhotonInit.cs but it wont work if youre setting up a local server, works well with photon cloud, i have no idea why.

Ive tried this but cant seem to make it work either.

void ShowServerEndpoint() {
2 UdpEndPoint serverEndPoint = BoltNetwork.server.remoteEndPoint;
3 Message.Show("Current Server", string.Format("({0}:{1}", serverEndPoint.Address, serverEndPoint.Port);
4 }

We're trying so that when people would instantiate a game and start a client, it would have a lobby and a list of session just like BoltPhotonInit.


Comments

  • Do you mean LAN broadcasting?
  • yes thats my intention
  • ive tried this.

    BoltNetwork.EnableLanBroadcast();
    BoltNetwork.SetHostInfo("MyGame", null);
    Debug.Log("Bolt started, enabling LAN boardcast - setting host info");

    but its not BoltNetwork.SessionList is empty.

    a guy said theres a method "RequestSessionList" that fills BoltNetwork.SessionList and i cant seem to find that method. its not in the Bolt Api, is it from udpkit.
  • yes ive tried the example and since BoltStarted() is not in anymore, i did the EnableBroadcast in BoltStartBegin() but SessionList is still empty and wont show session so ive tried it on SceneLoadLocalDone(), and the same thing , cant find the session SessionList . Is there any solution to this?

    Im thinking maybe at SceneLoadLocaldone() i create an event and put the player's ip4v address in the property of that event, my concern is how to access that property in realtime, or when another user starts the menuscene.
  • when i start as server, in the debug log, it says LAN endpoint resolved as [Endpoint :]. This endpoint is what I need to be broadcasted and i cant seem to find out how.
  • using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    using UdpKit;

    public class LocalBoltInit : Bolt.GlobalEventListener
    {
    enum State
    {
    SelectMode,
    SelectMap,
    ModeServer,
    ModeClient
    }

    State _state;

    NetworkPlayer ipaddress;

    string map;
    string _serverAddress = "10.128.171.58";
    protected string _lanAddress;

    int _lanServerPort = 25000;


    void Awake()
    {
    _lanServerPort = BoltRuntimeSettings.instance.debugStartPort;
    }

    public void StartServer()
    {
    if (_state == State.SelectMode)
    {
    BoltLauncher.StartServer(new UdpEndPoint(UdpIPv4Address.Any, (ushort)_lanServerPort));

    foreach (string value in BoltScenes.AllScenes)
    {
    if (SceneManager.GetActiveScene().name != value)
    {
    map = value;
    _state = State.ModeServer;

    }
    }
    }
    }

    public void StartClient()
    {
    if(_state == State.SelectMode)
    {
    BoltLauncher.StartClient(UdpEndPoint.Any);

    _state = State.ModeClient;
    }
    }

    void OnGUI()
    {
    switch (_state)
    {
    case State.ModeServer:
    if (BoltNetwork.isRunning && BoltNetwork.isServer)
    {
    BoltNetwork.LoadScene(map);
    }
    break;

    case State.ModeClient:
    GUILayout.BeginHorizontal();

    GUILayout.Label("Server IP: "); //placeholder
    //_lanAddress = Network.player.ipAddress.ToString();
    //_lanAddress = UdpIPv4Address.Localhost.ToString();
    _serverAddress = GUILayout.TextField(_serverAddress);

    foreach (var session in BoltNetwork.SessionList)
    {
    if (GUILayout.Button(session.Value.Source + " / " + session.Value.HostName + " (" + session.Value.Id + ")"))
    {
    BoltNetwork.Connect(session.Value);
    BoltNetwork.EnableLanBroadcast();
    Debug.LogError("Bolt started, enabling LAN boardcast - setting host info");
    }
    }

    if (GUILayout.Button("Connect"))
    {
    State_EnterServerIp();
    }

    GUILayout.EndHorizontal();
    break;
    }
    }

    void State_EnterServerIp()
    {
    if (BoltNetwork.isRunning && BoltNetwork.isClient)
    {
    BoltNetwork.Connect(new UdpEndPoint(UdpIPv4Address.Parse(_serverAddress), (ushort)_lanServerPort));
    }
    }

    bool ExpandButton(string text)
    {
    return GUILayout.Button(text, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
    }
    }

    and in my SErver call back its :::

    public override void SceneLoadLocalDone(string map)
    {
    BoltNetwork.EnableLanBroadcast((ushort)_lanServerPort);
    BoltNetwork.SetHostInfo("MyGame", null);
    BoltNetwork.Instantiate(BoltPrefabs.GameManagerObj);

    PlayerObjectRegistry.serverPlayer.Spawn();

    }



  • @stanchion Ive solved the problem by using a text file that is stored in a shared drive. EnableLanBroadcast never worked for me, it might be broken and needs to be checked. The solution I came up with does not relate to any Bolt "stuff" which is sad but it works for my case.
  • I don't follow at all with the issue you're having. You will can the ip from the session, and LanBroadcast doesn't guarantee you'll be able to see other people's sessions if there is any network issue.