Example #1
0
    public override void _Ready()
    {
        _network = (ServerNetwork)GetNode("/root/PaintNetwork");

        var buttonContainer = (Container)GetNode("CenterContainer/HBoxContainer/VBoxContainer");

        _start = (Button)buttonContainer.GetNode("Start");
        _stop  = (Button)buttonContainer.GetNode("Stop");

        _logContainer = (Container)GetNode("CenterContainer/HBoxContainer/ScrollContainer/VBoxContainer");

        _start.Connect("pressed", this, nameof(StartNetwork));
        _stop.Connect("pressed", this, nameof(StopNetwork));

        _network.Connect(nameof(ServerNetwork.NetworkConnected), this, nameof(LogMessageTag),
                         new Godot.Collections.Array {
            "NetworkConnected"
        });
        _network.Connect(nameof(ServerNetwork.NetworkDisconnected), this, nameof(LogMessageTag),
                         new Godot.Collections.Array {
            "NetworkDisconnected"
        });
        _network.Connect(nameof(ServerNetwork.LobbyUpdate), this, nameof(LogLobby));

        AddLogMessage("Test", "Message");
    }
Example #2
0
 private void StartNetwork()
 {
     _network.Connect();
 }